Nlog .. 2 questions .. singleton and calling class/method/thread?

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.

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.

I though a singleton would mean that it is only instantiated once .. I have a feeling I am confused about the way to use it.... – Adam Jun 19 '10 at 8:03 Create an instance of Logger in each class you want to use it in, yes... then just log through that logger. Yes, you'll end up creating more instances, but at the benefit of fine-grained configuration.It's not like it's going to load the whole assembly separately for each instance of Logger you build... – Jon Skeet Jun 19 '10 at 8:06 Jon .. I find your answers very helpful .. getting up to speed fast is frustrating .. the renderers page has solved my problem ... But by creating a separate log instance in every class I log .. what is the fin grained control I can have? Are you saying basically that I can switch on logging for just a certain class .. are there any other benefits.

ALSO .. seeing as you are being so helpful .. A have a single or may be 3 apps on a PC I want to log .. if I don't send them to a log file .. what way would you store them .. AND what viewer would you use to wade through the logs? – Adam Jun 19 '10 at 8:13 AL:SO is there a way to change the logging config while an app is running? – Adam Jun 19 '10 at 8:14 You know Jon .. the Renderers page .. it is blatantly obvious on the Documentation page .. how did I miss it .. I must have had my 'man eyes' on .. as my wife would say ... – Adam Jun 19 '10 at 8:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions