/// <summary>
/// 日志管理类
/// </summary>
public class LoggerManager
{
/// <summary>
/// Log4net日志静态对象
/// </summary>
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
static LoggerManager()
{
//注册log4net
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
}
<appender name="InfoLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log\\WS-Info-" />
<param name="StaticLogFileName" value="false"/>
<param name="LockingModel" value="log4net.Appender.FileAppender.MinimalLock"></param>
<appendToFile value="true" />
<datePattern value="yyyy-MM-dd".log"" />
<filter type="log4net.Filter.LevelRangeFilter">
<levelMax value="INFO"/>
<levelMin value="INFO"/>
</filter>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%class.%method]%message%newline"/>
</layout>
</appender>
如上的配置文件结果输出如下的 日志
[Utility.LoggerManager.Info]2016-05-09 15:16:55->定时器任务结束
我想输出的是执行方法名 而不是这个日志类的方法名啊
<param name="ConversionPattern" value="%d [%t] %-5p %c %l : %m%n" />