Add Enable and Disable Nlog Loggers programmatically?

To add: var logTarget = new ... logTarget. Layout = "Your layout format here"; // e.g. "${logger}: ${message} ${exception:format=tostring}"; // specify what gets logged to the above target var loggingRule = new LoggingRule("*", LogLevel. Debug, logTarget); // add target and rule to configuration LogManager.Configuration.

AddTarget("targetName", logTarget); LogManager.Configuration.LoggingRules. Add(loggingRule); LogManager.Configuration.Reload() Removal is done with LogManager.Configuration.LoggingRules. Remove(loggingRule); LogManager.Configuration.Reload().

To add: var logTarget = new ... logTarget. Layout = "Your layout format here"; // e.g. "${logger}: ${message} ${exception:format=tostring}"; // specify what gets logged to the above target var loggingRule = new LoggingRule("*", LogLevel. Debug, logTarget); // add target and rule to configuration LogManager.Configuration.

AddTarget("targetName", logTarget); LogManager.Configuration.LoggingRules. Add(loggingRule); LogManager.Configuration.Reload(); Removal is done with LogManager.Configuration.LoggingRules. Remove(loggingRule); LogManager.Configuration.Reload().

– Jon Sep 19 at 13:28 the thing is I already have loggers that log the system , all I need is the ability to enable them disable them at runtime , maybe disable them by loglevel too , so I was thinking of editing the config file then make the logmanager reload it (reconfigure it from config file) – Stacker Sep 19 at 13:29 @Stacker: That's a very roundabout way of doing so. You already have the API to enable and disable loggers: add or remove the rules that feed log events to them, as above. – Jon Sep 19 at 13:31 1 @Stacker: Glad to hear you solved it in the meantime.

Cheers! – Jon Sep 19 at 16:25.

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