Forum > Packages and Libraries

Usage of Lazlogger 2 - stop and start LOG file anyhow ? [solved]

(1/1)

PeterX:
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
- ???

Martin_fr:
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:

--- Quote from: Martin_fr on February 07, 2025, 07:47:35 pm ---   DebugLogger.Finish;
should close the handle.

--- End quote ---
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  :)

PeterX:

--- Quote from: PeterX on February 07, 2025, 07:41:48 pm ---Is there any save possibility to stop, save and close my file "at midnight"
to begin the new day with a new file ?

--- End quote ---

--- Quote from: Martin_fr on February 07, 2025, 07:47:35 pm ---   DebugLogger.Finish;
should close the handle.

--- End quote ---
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

Navigation

[0] Message Index

Go to full version