Recent

Author Topic: Usage of Lazlogger 2 - stop and start LOG file anyhow ? [solved]  (Read 472 times)

PeterX

  • Sr. Member
  • ****
  • Posts: 437
Usage of Lazlogger 2 - stop and start LOG file anyhow ? [solved]
« on: February 07, 2025, 07:41:48 pm »
Hi,

I found Lazlogger today, and I send some strings to a LOG file.

Is there any save possibility to stop, save and close my file "at midnight"
to begin the new day with a new file ?

- temporarily switch from "file" to stdout device ?
- CloseLogFileBetweenWrites
- ???
« Last Edit: February 12, 2025, 10:08:32 am by PeterX »
usually using latest Lazarus release version with Windows 10 or 11

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10921
  • Debugger - SynEdit - and more
    • wiki
Re: Usage of Lazlogger 2
« Reply #1 on: February 07, 2025, 07:47:35 pm »
Just from looking through the code

   DebugLogger.Finish;
should close the handle.

CloseLogFileBetweenWrites will do that too. If you are happy to reopen it for each write.
Also you can have CloseLogFileBetweenWrites = false, and then change it to true only when needed. It will close the handle if it is open (even if there is no log event/write)

PeterX

  • Sr. Member
  • ****
  • Posts: 437
Re: Usage of Lazlogger 2
« Reply #2 on: February 07, 2025, 07:59:13 pm »
   DebugLogger.Finish;
should close the handle.
Okay. I saw that procedure TLazLoggerFile.SetLogName(AValue: String);
also calls DebugLogger.Finish;

So I hope I can simply change the Name and DebugLogger will not chrash ... ?
I'll give it a try  :)
usually using latest Lazarus release version with Windows 10 or 11

PeterX

  • Sr. Member
  • ****
  • Posts: 437
Re: Usage of Lazlogger 2
« Reply #3 on: February 12, 2025, 10:08:04 am »
Is there any save possibility to stop, save and close my file "at midnight"
to begin the new day with a new file ?
   DebugLogger.Finish;
should close the handle.
Thanks for Your explanation, it works for me now.

Renaming the Logger File stops and closes the old LOG file at midnight.
And then starts writing into the new "next day" File, perfect !

BG Peter
usually using latest Lazarus release version with Windows 10 or 11

 

TinyPortal © 2005-2018