How to check whether a call to log4net's XmlConfigurator.Configure
succeeded? I want to make a web service call if the logging configuration could not be loaded properly (i.e. file not existent, file not well-formed, etc.)
From the FAQ:
To prevent silent failure of log4net as reported as LOG4NET-342, log4net supports a way to evaluate if it was configured and also to evaluate messages generated on startup since 1.2.11. To check if log4net was started and configured properly one can check the property
log4net.Repository.ILoggerRepository.Configured
and enumerate the configuration messages as follows:if(!log4net.LogManager.GetRepository().Configured) { // log4net not configured foreach(log4net.Util.LogLog message in log4net.LogManager.GetRepository().ConfigurationMessages.Cast<log4net.Util.LogLog>()) { // evaluate configuration message } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With