Nlog: AppDomain.CurrentDomain.ProcessExit logging?

Created on 20 Jul 2017  路  4Comments  路  Source: NLog/NLog

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?

question

Most helpful comment

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).

All 4 comments

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;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BobSeu picture BobSeu  路  3Comments

carkov1990 picture carkov1990  路  3Comments

linmasaki picture linmasaki  路  3Comments

haythamabutair picture haythamabutair  路  3Comments

MaximRouiller picture MaximRouiller  路  3Comments