Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 5 of 5 total |
Managing DBSRVR log file size |
Tue, Feb 5 2013 10:46 AM | Permanent Link |
Frank GlobeStar Systems (Connexall) | Hi Tim,
We've got a growing number of larger sites where our system runs for a significant period of time between restarts/reboots. Consequently, the DBSRVR.LOG file can grow excessively large over that time. One site reported a log file in excess of 30GB, although I'm a little suspicious of that claim. Indeed, any log file exceeding 10-20MB becomes somewhat problematical to retrieve [remotely via the server admin utility] and utilize. Ideally, we'd like to limit the log files to some arbitrary fixed size, and simply have them roll-over when that limit is reached. I've taken a spin through the "Customizing the Engine" chapter in the docs, and presumably we could try to implement the "OnServerX" events and compile a custom DBSRVR, but is there any other existing mechanism currently in DBSRVR that I'm overlooking that could address this? The only relevant INI setting that I can see relate to append/overwrite (we always stipulate the latter, but that doesn't help when dealing with the extended run times described above). Regards, Jason Wilson |
Wed, Feb 6 2013 4:18 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jason,
<< I've taken a spin through the "Customizing the Engine" chapter in the docs, and presumably we could try to implement the "OnServerX" events and compile a custom DBSRVR, but is there any other existing mechanism currently in DBSRVR that I'm overlooking that could address this? The only relevant INI setting that I can see relate to append/overwrite (we always stipulate the latter, but that doesn't help when dealing with the extended run times described above). >> Customizing is pretty much the only option at this point. Luckily, it's very easy to do and recompilation is also. What you want to do is add some logic in these event handlers to handle rolling over the log: procedure TMainForm.ServerEngineServerLogEvent(Sender: TObject; LogRecord: TLogRecord); begin FileSeek(LogFileHandle,0,2); FileWrite(LogFileHandle,LogRecord,SizeOf(TLogRecord)); end; procedure TMainForm.ServerEngineServerLogCount(Sender: TObject; var LogCount: Integer); var TotalLogSize: Integer; begin TotalLogSize:=FileSeek(LogFileHandle,0,2); LogCount:=(TotalLogSize div SizeOf(TLogRecord)); end; procedure TMainForm.ServerEngineServerLogRecord(Sender: TObject; Number: Integer; var LogRecord: TLogRecord); begin FileSeek(LogFileHandle,((Number-1)*SizeOf(TLogRecord)),0); FileRead(LogFileHandle,LogRecord,SizeOf(TLogRecord)); end; And I would be remiss to not mention that EDB does this already, and it's built-in. You just set the max log file size and off you go. Tim Young Elevate Software www.elevatesoft.com |
Thu, Feb 7 2013 4:03 AM | Permanent Link |
Jose Eduardo Helminsky HPro Informatica | Jason
I do exactly what Tim suggested and use very simple functions to create log day by day. procedure TFDBISamServer.FormCreate; begin FLogPath := ExtractFilePath(ParamStr(0)); FLogFile := PrepareLogFile; end; function TFDBISamServer.GetLogFileName: String; var nDow: Integer; begin nDow := DayOfWeek(Date); if nDow = 1 then Result := FLogPath + 'dbsrvr_dom.log' else if nDow = 2 then Result := FLogPath + 'dbsrvr_seg.log' else if nDow = 3 then Result := FLogPath + 'dbsrvr_ter.log' else if nDow = 4 then Result := FLogPath + 'dbsrvr_qua.log' else if nDow = 5 then Result := FLogPath + 'dbsrvr_qui.log' else if nDow = 6 then Result := FLogPath + 'dbsrvr_sex.log' else if nDow = 7 then Result := FLogPath + 'dbsrvr_sab.log' end; function TFDBISamServer.PrepareLogFile: Integer; var dLog: TDateTime; begin FLogFileName := GetLogFileName; if FileExists(FLogFileName) then begin FileAge(FLogFileName,dLog); if formatdatetime('dd/mm/yyyy',dLog) <> FormatDateTime('dd/mm/yyyy',Date) then begin DeleteFile(FLogFileName); Result := FileCreate(FLogFileName); end else begin Result := FileOpen(FLogFileName,fmOpenReadWrite or fmShareDenyNone); end; end else begin Result := FileCreate(FLogFileName); end; end; procedure TFDBISamServer.ServerEngineServerLogEvent(Sender: TObject; LogRecord: TLogRecord); begin if FLogFile <> 0 then begin if LogRecord.Category <> lcInformation then begin if FLogFileName <> GetLogFileName then begin FileClose(FLogFile); FLogFile := PrepareLogFile; end; FileSeek(FLogFile,0,2); FileWrite(FLogFile,LogRecord,SizeOf(TLogRecord)); end; end; end; procedure TFDBISamServer.ServerEngineServerLogCount(Sender: TObject; var LogCount: Integer); var TotalLogSize: Integer; begin if FLogFile <> 0 then begin TotalLogSize := FileSeek(FLogFile,0,2); LogCount := (TotalLogSize div SizeOf(TLogRecord)); end; end; procedure TFDBISamServer.ServerEngineServerLogRecord(Sender: TObject; Number: Integer; var LogRecord: TLogRecord); begin if FLogFile <> 0 then begin FileSeek(FLogFile,((Number-1)*SizeOf(TLogRecord)),0); FileRead(FLogFile,LogRecord,SizeOf(TLogRecord)); end; end; Eduardo |
Thu, Feb 7 2013 10:15 AM | Permanent Link |
Frank GlobeStar Systems (Connexall) | Thanks for the timely feedback, Tim!
Cheers, Jason |
Thu, Feb 7 2013 10:16 AM | Permanent Link |
Frank GlobeStar Systems (Connexall) | Eduardo,
Thanks so much for taking the time to share your code. It's greatly appreciated! Regards, Jason |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |