NLog in a Web Service

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

NLog in a Web Service

-david-
Quick question:
Does nlog expect to be set up as public static Logger in the main service class and then have each subsequent class use the public Logger, or is each class supposed to declare its own private Logger?
Reply | Threaded
Open this post in threaded view
|

Re: NLog in a Web Service

Jarek Kowalski
Administrator
Each logger represents a single source of log messages. Once you have multiple sources you can filter the messages by source at runtime.

It's generally recommended for each class to use:

private static Logger logger = LogManager.GetCurrentClassLogger();

which creates a logger based on full class name (including namespace).

It's not the requirement, you can of course use logger per method or one logger per your application, if you don't care about sources. It's up to you.
NLog Blog