Log4net: How to enable debug logging at runtime?
问题 In the test environment, the debug log is enabled, so I can see detailed debug log messages. In production environment, I want to disable debug log by default, but still want to enable/disable it if needed. Can I enable debug log at runtime without restarting my application? My logging code looks like below: if(logger.IsDebugEnabled) Logger.Debug("debug message"); 回答1: You can change to loglevel by setting it and then apply the new settings: ((log4net.Repository.Hierarchy.Hierarchy)LogManager