EDN Admin
Well-known member
Hi all,
Ill try to explain my question in simple way.
I can implement log4net in C#.Net quite easily. But what I want to do is to log details into multiple files. For example say I have two methods in an application. I want to attach two logs file into those two functions and log details separately. So both
file can contain ERROR, WAN, INFO thresholds.
My App.config file looks like this,
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; appender <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "LogFileAppender" <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Appender.RollingFileAppender" <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "File" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ResultsLogslog.txt" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "AppendToFile" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; rollingStyle <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "Size" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maxSizeRollBackups <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "1000" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maximumFileSize <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "20KB" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; staticLogFileName <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; layout <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Layout.PatternLayout"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "ConversionPattern" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "[%d{yyyy-MM-dd hh:mm:ss}] - [%-5p] – %m%n" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; layout<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; appender<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; appender <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "EventAppender" <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Appender.RollingFileAppender" <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "File" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ResultsLogsevent.txt" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "AppendToFile" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; rollingStyle <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "Size" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maxSizeRollBackups <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "1000" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maximumFileSize <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "20KB" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; staticLogFileName <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; layout <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Layout.PatternLayout"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "ConversionPattern" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "[%d{yyyy-MM-dd hh:mm:ss}] - [%-5p] – %m%n" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; layout<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; appender<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; root<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; level <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ALL" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; appender-ref <span style="color:Red; ref<span style="color:Blue; =<span style="color:Blue; "LogFileAppender" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; appender-ref <span style="color:Red; ref<span style="color:Blue; =<span style="color:Blue; "EventAppender" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; root<span style="color:Blue; >
[/code]
<br/>
But I couldnt initiate the ILog object with the required appender. Could anyone of you please help me to solve this.
View the full article
Ill try to explain my question in simple way.
I can implement log4net in C#.Net quite easily. But what I want to do is to log details into multiple files. For example say I have two methods in an application. I want to attach two logs file into those two functions and log details separately. So both
file can contain ERROR, WAN, INFO thresholds.
My App.config file looks like this,
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; appender <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "LogFileAppender" <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Appender.RollingFileAppender" <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "File" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ResultsLogslog.txt" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "AppendToFile" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; rollingStyle <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "Size" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maxSizeRollBackups <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "1000" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maximumFileSize <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "20KB" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; staticLogFileName <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; layout <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Layout.PatternLayout"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "ConversionPattern" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "[%d{yyyy-MM-dd hh:mm:ss}] - [%-5p] – %m%n" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; layout<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; appender<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; appender <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "EventAppender" <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Appender.RollingFileAppender" <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "File" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ResultsLogsevent.txt" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "AppendToFile" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; rollingStyle <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "Size" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maxSizeRollBackups <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "1000" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; maximumFileSize <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "20KB" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; staticLogFileName <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "true" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; layout <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "log4net.Layout.PatternLayout"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Blue; "ConversionPattern" <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "[%d{yyyy-MM-dd hh:mm:ss}] - [%-5p] – %m%n" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; layout<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; appender<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; root<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; level <span style="color:Red; value<span style="color:Blue; =<span style="color:Blue; "ALL" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; appender-ref <span style="color:Red; ref<span style="color:Blue; =<span style="color:Blue; "LogFileAppender" <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; appender-ref <span style="color:Red; ref<span style="color:Blue; =<span style="color:Blue; "EventAppender" <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; root<span style="color:Blue; >
[/code]
<br/>
But I couldnt initiate the ILog object with the required appender. Could anyone of you please help me to solve this.
View the full article