Reputation: 2757
It is possible to change log4net logging level without restart ASP.NET application. Some possible ways to configure log4net configuration are:
[assembly:log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config",Watch=true)]
Changing the configuration in a web.config file will restart the application. If I don't want to restart the application, is it recommended to use the separate configuration file or is there any different approach for this?
Upvotes: 7
Views: 3128
Reputation: 14972
If you set an external configuration file and set its watch to true you can indeed change the logging configuration without restarting the application:
Watch
If this flag is specified and set to true then the framework will watch the configuration file and will reload the config each time the file is modified.
from the configuration page
There are some other ways to do it, namely you can change the configuration through code but why would you want to do that since you can as well change the configuration file. In the end, implementing other ways than the config file to change logging at runtime isn't very effective, so don't bother :)
Upvotes: 9