Sign in Join
Wiki copytemporary

Enabling LazLogger and Application Exception Dump: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Since the release of Lazarus 2.0.0, LCL applications by default do no longer have LazLogger enabled, nor do they do an application exception dump (using debugln) when an application crashes (see: [[Lazarus 2.0.0 release notes|Lazarus_2.0.0_release_notes#No_default_LazLogger]] and [[Lazarus 2.0.0 release notes|Lazarus_2.0.0_release_notes#No_LCL_Application_exception_dump]] for an explantion why).
22
33Especially for the debug build mode of your application, it is very usefull to have these two features enabled.
44In [[Lazarus 2.0.0 release notes|this section of the 2.0 releae notes]] it is suggested to add `-FaLCLExceptionStacktrace,LazLogger` to "Additions and Overrides" of the Compiler Options of the debug build mode.
55While this works just fine on Windows, on Linux and Amiga (at least) this will cause your application to crash, since these units need a threadmanger to be active and using the "-Fa" option for the compiler wil load these units before any uses clause is parsed, so no threadmanager will activated yet.
66
77A different solution is to create a dedicated unit for the sole purpose of initializing application exception dumping and logging using debugln.
88In this unit you will then make sure a threadmanager is used (as the first unit in the uses clause).
99
1010Example:
1111```
1212unit LCLDebug;
1313 {$mode objfpc}
1414 {$h+}
1515
1616 {
1717 Activates logging and backtrace capabilities for Lazarus Applications
1818
1919 The recommended way to use this is by using the -Fa paramter for the compiler:
2020 -FaLCLDebug
2121
2222 This can be set in Project Options -> Cmpiler Options -> Custom Options in Lazarus IDE.
2323 The idea is that you uses this in the "debug" build mode.
2424
2525 You should use the LazLoggerBase unit in any unit from your program that uses the
2626 Debugln() procedure: it won't output anything by default.
2727 (Using LazLogger unit overrides this behaviour then).
2828
2929 Copyright (C) 2025 by FlyingSheep Inc. and Bart Broersma
3030 }
3131
3232 interface
3333
3434 uses
3535 {$IFDEF UNIX}
3636 cthreads,
3737 {$ENDIF}
3838 {$IFDEF HASAMIGA}
3939 athreads,
4040 {$ENDIF}
4141 LazLogger, //enables debugln() etc
4242 LCLExceptionStacktrace; //enables backtracing on exceptions
4343 implementation
4444
4545 initialization
4646 //empty section to fool the compiler that the unit actually does something, so it doesn't emit the "unit LCLDebug not used in ..." hint.
4747
4848 end.
4949```
5050
5151Now, in the compiler options for your debug build mode, you go to "Custom Options" and add "-FaLCLDebug" (without the quotes).
5252[![custom options lcldebug.png](/wiki-images/5/53/custom_options_lcldebug.png)](</File:custom_options_lcldebug.png>)
5353
5454---
55-*From the Free Pascal wiki, page "Enabling LazLogger and Application Exception Dump", as the Internet Archive kept it on 2026-01-05. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
55+*From the Free Pascal wiki, page "Enabling LazLogger and Application Exception Dump", as the Internet Archive kept it on 2026-01-05, last changed on 2026-01-03. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history