日期:2014-05-17 浏览次数:20942 次
<!--日志记录器logger可以有多个-->
<logger name="logger_yule">
<level value="ALL"/>
<appender-ref ref="LogFileAppender_yule" />
</logger>
<logger name="logger_tiyu">
<level value="ALL"/>
<appender-ref ref="LogFileAppender_tiyu" />
</logger>
<!--1、一个appender可以被多个logger共用-->
<!--2、logger可以同时引用多个appender-->
<appender name="LogFileAppender_yule" type="log4net.Appender.FileAppender" >
<param name="File" value="C:\娱乐新闻\weblog.txt" />
...
</appender>
<appender name="LogFileAppender_tiyu" type="log4net.Appender.FileAppender" >
<param name="File" value="C:\体育新闻\weblog.txt" />
...
</appender>
public static void Error_yule(string message)
{
log4net.ILog log = log4net.LogManager.GetLogger("LogFileAppender_yule");
if (log.IsErrorEnabled)
{
log.Error(message);
}
log = null;
}
public static void Error_tiyu(string message)
{
log4net.ILog log = log4net.LogManager.GetLogger("LogFileAppender_tiyu");
if (log.IsErrorEnabled)
{
log.Error(message);
}
log = null;
}