danieleteti / loggerpro

An modern and pluggable logging framework for Delphi
Apache License 2.0
352 stars 91 forks source link

Application Freeze on freelibrary with dll using LoggerPro #74

Closed Basti-Fantasti closed 1 year ago

Basti-Fantasti commented 1 year ago

I ran into this problem, that my application crashes / freezes every time when it gets shut down on the FreeLibrary call.

In that call, the LoggerPro destructor is called like this:

destructor TLogging.Destroy;
begin

  if self <> nil then
  begin
    _Log := nil;
    if System.IsLibrary then
    begin
      ReleaseGlobalLogger; // This is required inside dll and ISAPI!!
    end;
end;

it always freezes at the _Log := nil call. I have implemented the ReleaseGlobalLogger; but this is never executed due to the freeze in the row before. It seems to make no difference which loggers are used.

I tried only the FileLogger, only Syslog, but as soon as one instance of the logger is running, the calling App freezes...

Do you have any ideas what could cause this, or how can I further investigate into this...

Basti-Fantasti commented 1 year ago

I managed to successfully circumvent the issue by calling the logging class destructor before calling the FreeLibrary (as suggested by you 😃 )

Now it works...

I also implemented your singleton approach for building the Logger as well as freeing the logger