< configSections >
< section name = "log4net" type = "log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</ configSections >
< log4net >
<!--定义输出到文件中-->
< appender name = "LogFileAppender" type = "log4net.Appender.FileAppender" >
<!--定义文件存放位置-->
< file value = "logs/log4netfile.txt" />
< appendToFile value = "true" />
< rollingStyle value = "Date" />
< datePattern value = "yyyyMMdd-HH:mm:ss.SSS" />
< layout type = "log4net.Layout.PatternLayout" >
<!--输出格式-->
<!--样例:2008-03-26 13:42:32,111 [10] INFO Log4NetDemo.MainClass [(null)] - info-->
< conversionPattern value = "%date %thread %-5level %logger property:[%property{NDC}] - %message%newline" />
</ layout >
</ appender >
<!--定义输出到控制台命令行中-->
< appender name = "ConsoleAppender" type = "log4net.Appender.ConsoleAppender" >
< layout type = "log4net.Layout.PatternLayout" >
< conversionPattern value = "%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</ layout >
</ appender >
< root >
<!--控制台控制显示日志-->
< appender-ref ref = "ConsoleAppender" />
< appender-ref ref = "LogFileAppender" />
</ root >
</ log4net >
|