Log4j.xml配置

  
  
  
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> 
  3.     <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" 
  4.     debug="false"> 
  5.         <appender name="ERROR_FILE_APPENDER" class="org.apache.log4j.RollingFileAppender"> 
  6.             <param name="Append" value="true" /> 
  7.             <param name="Threshold" value="ERROR" /> 
  8.             <param name="File" value="${bazas_admin_logdir}/bazas_admin_error.log" /> 
  9.             <param name="MaxFileSize" value="5MB" /> 
  10.             <param name="MaxBackupIndex" value="10" /> 
  11.             <layout class="org.apache.log4j.PatternLayout"> 
  12.                 <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%-c] %m%n" /> 
  13.             </layout> 
  14.         </appender> 
  15.         <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> 
  16.             <param name="Append" value="true" /> 
  17.             <param name="Threshold" value="WARN" /> 
  18.             <param name="File" value="${bazas_admin_logdir}/bazas_admin.log" /> 
  19.             <param name="MaxFileSize" value="20MB" /> 
  20.             <param name="MaxBackupIndex" value="30" /> 
  21.             <layout class="org.apache.log4j.PatternLayout"> 
  22.                 <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%-c] %m%n" /> 
  23.             </layout> 
  24.         </appender> 
  25.         <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> 
  26.             <param name="Target" value="System.out" /> 
  27.             <param name="Threshold" value="INFO" /> 
  28.             <layout class="org.apache.log4j.PatternLayout"> 
  29.                 <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1}] %m%n" /> 
  30.             </layout> 
  31.         </appender> 
  32.         <category name="org.springframework"> 
  33.             <priority value="ERROR" /> 
  34.         </category> 
  35.         <category name="org.apache.velocity"> 
  36.             <priority value="ERROR" /> 
  37.         </category> 
  38.         <logger name="com.alibaba.bazas"> 
  39.             <appender-ref ref="ERROR_FILE_APPENDER" /> 
  40.             <appender-ref ref="EXCEPTION_LOG"/> 
  41.         </logger> 
  42.         <root> 
  43.             <level value="WARN" /> 
  44.             <appender-ref ref="CONSOLE" /> 
  45.             <appender-ref ref="FILE" /> 
  46.             <appender-ref ref="EXCEPTION_LOG"/> 
  47.         </root> 
  48.     </log4j:configuration> 

<root>标签对应log4j.properties中的rootLogger

<logger>是指继承自rootLogger的subLogger

<appender>中定义loglevel,append type, 文件大小

<logger>标签中定义此路径下统一使用的logging settings

你可能感兴趣的:(职场,休闲,log4j.xml,labels)