properties配置 #production release log4j.rootLogger = info, stdout, F, error 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 = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n log4j.appender.F = org.apache.log4j.DailyRollingFileAppender log4j.appender.F.File = /usr/local/logs/test_default.log log4j.appender.F.layout = org.apache.log4j.PatternLayout log4j.appender.F.Threshold = INFO log4j.appender.F.DatePattern = '_'yyyy-MM-dd'.log' log4j.appender.F.layout.ConversionPattern = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n log4j.logger.error=error log4j.appender.error = org.apache.log4j.DailyRollingFileAppender log4j.appender.error.File = /usr/local/logs/test_error.log log4j.appender.error.layout = org.apache.log4j.PatternLayout log4j.appender.error.Threshold = ERROR log4j.appender.error.DatePattern = '_'yyyy-MM-dd'.log' log4j.appender.error.layout.ConversionPattern = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n XML 配置如下:<?xml version="1.0" encoding="UTF-8" ?> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jakarta.apache.org/log4j/"> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c.%M | %m%n"/> </layout> </appender> <appender name="file" class="org.apache.log4j.DailyRollingFileAppender"> <param name="file" value="/usr/local/logs/test.log"/> <param name="Append" value="true" /> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c.%M | %m%n"/> </layout> </appender> <logger name="com.test.ccc"> <level value="debug"/> </logger> <logger name="org.springframework.ws.client.MessageTracing"> <level value="trace"/> </logger> <logger name="org.springframework.ws.server.MessageTracing"> <level value="trace"/> </logger> <root> <priority value="info"/> <appender-ref ref="console"/> <appender-ref ref="file"/> </root> </log4j:configuration>
log4j配置
最新推荐文章于 2024-06-28 09:15:00 发布