本文共 2441 字,大约阅读时间需要 8 分钟。
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"/></configuration>
log4j配置:
log4j.rootLogger=info,D,E
log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n#stdoutlog4j.logger.info=Dlog4j.appender.D=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.D.File=/home/weblogic/logs/prepo/jfpay_prepo_info.loglog4j.appender.D.Append = truelog4j.appender.D.Threshold = infolog4j.appender.D.layout=org.apache.log4j.PatternLayoutlog4j.appender.D.layout.ConversionPattern=%d %p [%c] - %m%nlog4j.logger.error=E
log4j.appender.E=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.E.File=/home/weblogic/logs/prepo/error/jfpay_prepo_error.loglog4j.appender.E.Append = truelog4j.appender.E.Threshold = errorlog4j.appender.E.layout=org.apache.log4j.PatternLayoutlog4j.appender.E.layout.ConversionPattern=%d %p [%c] - %m%n以上配置仅供参考
转载于:https://blog.51cto.com/13545923/2053384