NLog. singleton and calling class/method/thread
just trying to get up to speed fast.
2 questions ..
My intention was to have a singleton class to make NLog available to the whole application .. is th开发者_如何转开发is the correct approach.
How do I record the source i.e. Class .. Method .. thread etc. of the entry in the log.
What would your singleton do exactly?
One of the advantages of libraries like NLog (and log4j etc) is that when you log, it will log with the relevant class logger - which means you can then tune the logging appropriately. If you had some singleton with just a single Logger
instance, you would immediately lose this benefit. I would recommend you use the technique shown in the documentation, where each class has its own logger.
As for emitting the class name etc, look at the layout renderers page of the docs, which has many options: {callsite}
and {threadid}
may be what you're after.
精彩评论