Type : Question / Bug
NLog version: 4.4.11
Platform: .Net 4.6.2
Current NLog config: any log to File, for example default one.
NLog doesn't provide any output in AppDomain.CurrentDomain.ProcessExit handler. No errors (in internal log too), and no output.
Any tips?
Maybe if you make sure to register your own event-handler to AppDomain.CurrentDomain.ProcessExit before you initialize / access any NLog-objects (Be aware of static initialization of NLog-logger-objects).
@snakefoot You are right, all ok now, thanks a lot.
It's inconvenient to register own ProcessExit before any logging, because I one usually init private static Logger log as the first line in the class. I would prefer something like
c#
LogManager.DisableAutoShutdown();
AppDomain.CurrentDomain.ProcessExit += (s, e) =
{
// ... own code
LogManager.Shutdown();
};
@xmedeko NLog 4.6.8 introduces the following property (Can also be configured in NLog.config):
NLog.LogManager.AutoShutdown = false;
Most helpful comment
Maybe if you make sure to register your own event-handler to
AppDomain.CurrentDomain.ProcessExitbefore you initialize / access any NLog-objects (Be aware of static initialization of NLog-logger-objects).