Forum > Packages and Libraries

Usage of Lazlogger

(1/2) > >>

superc:
Hello,

I'm not understand how use Lazlogger works: I imported uses lazlogger  but now what I have to do? I can't figure out from the documentation which object to instantiate to define the output file....

Thanks in advance.

cdbc:
Hi
AFAIK you 'uses' LazLogger only in your main unit and then 'uses' LazLoggerBase in the other units you want to enable logging in.
Then it's a matter of using the methods of the base logger class...
Regards Benny

superc:
Thank you, I've moved unit LazLogger into main unit and LazLoggerBase in other unit, now I want set filenamepath of log for output file from code now what I can't understand is where I can set the log filename, because in LazLoggerBase can't find how to set the name... thanks in advance

Martin_fr:
https://wiki.freepascal.org/LazLogger

superc:

--- Quote from: Martin_fr on July 04, 2024, 12:54:18 pm ---https://wiki.freepascal.org/LazLogger

--- End quote ---
I report what interests me:


--- Quote ---File
Debug output can also be written to file. The initialization code of the logging unit

checks your program's command line parameters for --debug-log=<file> (In Lazarus: Run / Run Parameters / Command line parameters). On finding this parameter, any subsequent debug output is sent to <file>.
The param name can be changed with DebugLogger.ParamForLogFileName:='--debug-log'; This property exists only if the unit LazLogger is used. (LazLoggerBase does not define this property)
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. E.g. for Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in that environment variable as file to receive debug output.
Example: if you do:

set lazarus_debuglog=c:\lazarus\debug.txt
and run Lazarus, debug output will be written to c:\lazarus\debug.txt.

--- End quote ---

so if I wanted to set the log file, without going through run-parameter, should I define an environment variable?
I find this solution embarrassing to say the least

Navigation

[0] Message Index

[#] Next page

Go to full version