I have a framework that uses log4net for logging, I know that we can disable or enable the desired logging in log4net via the config file.I want to develop some settings class so that the admin or user can set the logging etc.. What is the class etc in log for net to get the config file and change the settings in the config file via code? (are there any or should I use .net System.Xml) Any code snippets?
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<root>
<level value="ALL" />
<!--<appender-ref ref="LogFileAppender" />-->
<!--<appender-ref ref="ConsoleAppender" />-->
<appender-ref ref="DEBUG-RollingLogFileAppender" />
<appender-ref ref="Error-RollingLogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
<param name="File" value="log-file.txt" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[Header]\r\n"/>
<param name="Footer" value="[Footer]\r\n"/>
<param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />
</layout>
</appender>
<appender name="DEBUG-RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="..\\logs\\debug" />
<param name="AppendToFile" value="true" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value=".yyyyMMdd'.log'" />
<param name="MaxSizeRollBackups" value="30" />
<param name="MaximumFileSize" value="5MB" />
<layout type="log4net.Layout.PatternLayout,log4net">
<!--<param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />-->
<param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<!--<levelMin value="INFO" />-->
<levelMax value="INFO" />
</filter>
</appender>
<appender name="Error-RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="Threshold" value="WARN"/>
<param name="File" value="..\\logs\\errors" />
<param name="AppendToFile" value="true" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value=".yyyyMMdd'.log'" />
<param name="MaxSizeRollBackups" value="30" />
<param name="MaximumFileSize" value="5MB" />
<layout type="log4net.Layout.PatternLayout,log4net">
<header value=" " />
<footer value=" ======================================================================" />
<param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
</layout>
</appender>
</log4net>