Code Coverage by Clover.NET

 « Return to Thread: Stopping/Starting NLog on runtime?

Re: Stopping/Starting NLog on runtime?

by FIB :: Rate this Message:

Reply to Author | View in Thread

Hey Boersnoes,

thanks for your answer, but this would change the config-file anyway, which isn't possible for me.
But after a deeper research in the sourcefiles I found a possibility:

if(chkLogger.Checked)
                        {
                                NLog.Config.SimpleConfigurator.ConfigureForFileLogging("Logfile.log", NLog.LogLevel.Trace);
                        }
                        else
                        {
                                NLog.Config.SimpleConfigurator.ConfigureForFileLogging("Logfile.log", NLog.LogLevel.Off);
                        }

This allows me to set the level during runtime and 'off' means no logging. Maybe I didn't make clear what I actually wanted ;)
The initial logging starts (or not) through the original config file, until the logging status is load and set.

 « Return to Thread: Stopping/Starting NLog on runtime?

LightInTheBox - Buy quality products at wholesale price