How can I change the log level at run time, using semantic logging?
In my Global.asax Application_Startup I have the following code:
var listener = new ObservableEventListener();
listener.EnableEvents((EventSource) MyCustomEventSource.Log, EventLevel.Informational, Keywords.All);
listener.LogToRollingFlatFile(@"logs\events.json", 5000, "MM-dd-yyyy",
RollFileExistsBehavior.Increment,
RollInterval.Week,
new JsonEventTextFormatter(), 4);
How can I change the log level once the my process has started. My support team may want to turn up logging to Verbose during a troubleshooting session, and then turn it back down once they find the problem. They want to do this without stopping or restarting the process.
First, I strongly recommend using the out-of-process host for production. The reasons for this are primarily performance related.
Dynamic configuration is a feature of the out-of-process service. All you need to do is modify the level
attribute on the corresponding <eventSource />
and the change should be picked up automatically.
Here's an example configuration.