log4j配置文件

log4j.properties

log4j.rootLogger=info, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c - %m%n


log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File= ../tp/logs/MichelleServer_debug.log
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.Append = true
log4j.appender.R.Threshold = DEBUG
log4j.appender.R.MaxFileSize=2048KB
log4j.appender.R.MaxBackupIndex=100
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %p %c - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File= ../tp/logs/MichelleServer_error.log
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.Append = true
log4j.appender.R.Threshold = ERROR
log4j.appender.R.MaxFileSize=2048KB
log4j.appender.R.MaxBackupIndex=100
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %p %c - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File= ../tp/logs/MichelleServer_info.log
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.Append = true
log4j.appender.R.Threshold = INFO
log4j.appender.R.MaxFileSize=2048KB
log4j.appender.R.MaxBackupIndex=100
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %p %c - %m%n

log4j.logger.org.hibernate=INFO
#log4j.logger.org.hibernate=DEBUG

 

log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 <appender name="rollingFile" class="org.apache.log4j.RollingFileAppender">
  <param name="File" value="../server/default/tp/logs/MichelleV7.log"/>
  <param name="MaxFileSize" value="2048KB"/>
  <param name="MaxBackupIndex" value="100"/>
  <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %C - %m%n"/>
  </layout>
 </appender>

       <appender name="ST_DEBUG" class="org.apache.log4j.DailyRollingFileAppender">    
       <param name="File" value="../tp/logs/MichelleV7_debug.log" />
       <param name="DatePattern" value="'-'yyyy-MM-dd'.log'" />
   <param name="Append" value="true" />
   <param name="Threshold" value="DEBUG"/>
      <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{yy-MM-dd HH:mm:ss,SSS} %-5p %c - %m%n"/>    
      </layout>
      </appender>
  
      <appender name="ST_INFO" class="org.apache.log4j.DailyRollingFileAppender">    
       <param name="File" value="../tp/logs/MichelleV7_info.log" />
       <param name="DatePattern" value="'-'yyyy-MM-dd'.log'" />
   <param name="Append" value="true" />
   <param name="Threshold" value="INFO"/>
      <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{yy-MM-dd HH:mm:ss,SSS} %-5p %c - %m%n"/>    
      </layout>
     </appender>

     <appender name="ST_ERROR" class="org.apache.log4j.DailyRollingFileAppender">    
       <param name="File" value="../tp/logs/MichelleV7_error.log" />
       <param name="DatePattern" value="'-'yyyy-MM-dd'.log'" />
   <param name="Append" value="true" />
   <param name="Threshold" value="ERROR"/>
      <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{yy-MM-dd HH:mm:ss,SSS} %-5p %c - %m%n"/>    
      </layout>
     </appender>

        <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
  <param name="Target" value="System.out"/>
  <param name="Threshold" value="INFO"/>
  <layout class="org.apache.log4j.PatternLayout"> 
   <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %C - %m%n"/>
  </layout>
 </appender>
 
 <appender name="asyncAppender" class="org.apache.log4j.AsyncAppender">   
  <param name="BufferSize" value="512"/>   
  <appender-ref ref="rollingFile"/>
 </appender>

 <logger name="org.hibernate">
  <level value="ERROR"/>
 </logger>

 <logger name="org.hibernate.SQL">
  <level value="ERROR"/>
 </logger>
 
 <logger name="com.opensymphony">
  <level value="ERROR"/>
 </logger>
 
 <logger name="com.opensymphony.xwork2.interceptor">
  <level value="ERROR"/>
 </logger>
 
 <logger name="com.opensymphony.xwork2.util">
  <level value="ERROR"/>
 </logger>
 
 <logger name="com.freemarker.log">
  <level value="ERROR"/>
 </logger>
 
 <logger name="org.apache.struts2.components">
  <level value="ERROR"/>
 </logger>
 
 <logger name="com.opensymphony.xwork2.ognl.OgnlValueStack">
  <level value="ERROR"/>
 </logger>

 <logger name="org.apache.struts2.util.TextProviderHelper">
  <level value="ERROR"/>
 </logger>

 <root>
  <level value="INFO"/>
  <appender-ref ref="rollingFile"/>
                <appender-ref ref="CONSOLE"/>
                <appender-ref ref="ST_DEBUG" />
  <appender-ref ref="ST_INFO" />
  <appender-ref ref="ST_ERROR" />
 </root>
 
</log4j:configuration>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值