Reputation: 533
I am trying to check whether the log is enabled or disabled based on the ini file. But i will have to check this condition every time whether it is enabled or disabled. I will have to check this log file is enabled or disabled once and then use it everywhere. How can I do this?
if ("true".Equals(m_objGlobalConfig.SoapLog))
{
log.ErrorFormat(se.Message + Environment.NewLine + Environment.NewLine, se.StackTrace);
}
Is there anything I can do this customization for the appender ?
Upvotes: 1
Views: 387
Reputation: 14962
You could simply disable the log4net initialization based on this parameter, this would prevent log4net from being configured and logging:
During the initialization of your program just do :
if ("true".Equals(m_objGlobalConfig.SoapLog))
{
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("path/to/file"));
}
and then you can log normally
Upvotes: 1