Well, it is supposed to be threadsafe. If it has bugs they need to be reported and addressed.
The memory leak I have indeed seen too, but not yet had time to take care of it. (Also I can't reproduce it at will).
In which units you use LazLogger vs LazLoggerBase does not matter. As long as you have LazLogger in at least one unit. All that does is it registers the real logger. LazLoggerBase registers a logger that discards everything.
Mind
https://wiki.freepascal.org/LazLogger#MultithreadingThe creation/setup/destruction/configuration of the logger is not thread-safe
And, I just spotted this also said:
Creation is usually done automatically during unit initialization.
which is wrong.
If you don't call "LazLogger" (the property), then creation is done in the first call to "debugln" (or dbgout). I changed that.
So if your first debugln happens while you already have threads, and several debugln attempt to create the logger, then that is a problem (which was meant to be documented, and now is documented).
To remedy, just access the "LazLogger" property once before starting any thread.
If other parts fail within threads for you, then please report that.
Mind you can try and play around with LazLogger.FileHandle.
By default it is set to
LazLogger.FileHandle := TLazLoggerFileHandleMainThread.Create;
If you change that, you must repeat changes you made to the "LogName" or "UseStdOut" properties.
There is another class called TLazLoggerFileHandleThreadSave.
It will do logging inside each thread (the OS/WS must allow file-handles to be accessed from different threads / done in critical section).
On the upside, you main thread doesn't need to run Synchronize. (Normally done automatically, if you have a standard GUI app)
On the downside, if your StdOut or filehandle isn't yet open, and your first debugln is in a thread the TLazLoggerFileHandleThreadSave will create the handle inside this thread. And on some OS/WS it will become unusable if that thread terminates.
TLazLoggerFileHandleMainThread does always create handles in the main thread (IIRC / it should).