logback.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] %class:%line >> %msg%n</pattern>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/report/logs/opt/jfpay_task_bat_log/task.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>/home/report/logs/opt/jfpay_pm_out_log/task.%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</Pattern>
</encoder>
</appender>
<appender name="job-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/report/logs/opt/jfpay_pm_out_log/job.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>/home/report/logs/opt/jfpay_pm_out_log/task.%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</Pattern>
</encoder>
</appender>
<logger name="org.springframework" level="warn"/>
<logger name="org.apache.ibatis" level="debug"/>
<logger name="com.jfpay" level="debug"></logger>
<root level="debug">
<appender-ref ref="stdout" />
<appender-ref ref="file" />
</root>
</configuration>
log4j配置:
log4j.rootLogger=info,D,E log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n #stdout log4j.logger.info=D log4j.appender.D=org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File=/home/weblogic/logs/prepo/jfpay_prepo_info.log log4j.appender.D.Append = true log4j.appender.D.Threshold = info log4j.appender.D.layout=org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.logger.error=E log4j.appender.E=org.apache.log4j.DailyRollingFileAppender log4j.appender.E.File=/home/weblogic/logs/prepo/error/jfpay_prepo_error.log log4j.appender.E.Append = true log4j.appender.E.Threshold = error log4j.appender.E.layout=org.apache.log4j.PatternLayout log4j.appender.E.layout.ConversionPattern=%d %p [%c] - %m%n
以上配置仅供参考