log4j最佳配置备份
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <!-- 业务日志,生产环境使用。hekun --> <appender name="BCSS_LOG" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="log/bcss.log" /> <param name="Append" value="true" /> <param name="DatePattern" value="'.'yyyy-MM-dd-HH" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %t [%-5p] (%F,%L) - %m%n" /> </layout> </appender> <!-- JOP框架底层日志,分析框架问题时使用。hekun --> <appender name="JOP_LOG" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="log/jop.log" /> <param name="Append" value="true" /> <param name="DatePattern" value="'.'yyyy-MM-dd-HH" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %t (%F,%L) - %m%n" /> </layout> </appender> <!-- 控制台日志,开发阶段使用--> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <param name="Threshold" value="DEBUG"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %t [%-5p](%F,%L) - %m%n" /> </layout> </appender> <!-- 默认的异步文件日志输出,生产环境都采用此appender --> <appender name="ASYNC_BCSS_LOG" class="org.apache.log4j.AsyncAppender"> <param name="BufferSize" value="256"/> <param name="LocationInfo" value="true"/> <appender-ref ref="BCSS_LOG"/> </appender> <!-- 默认的异步文件日志输出,生产环境都采用此appender --> <appender name="ASYNC_JOP_LOG" class="org.apache.log4j.AsyncAppender"> <param name="BufferSize" value="512"/> <param name="LocationInfo" value="true"/> <appender-ref ref="JOP_LOG"/> </appender> <!-- console 异步日志,开发环境都使用此appender,方便调试 --> <appender name="ASYNC_CONSOLE" class="org.apache.log4j.AsyncAppender"> <param name="BufferSize" value="64"/> <param name="LocationInfo" value="true"/> <appender-ref ref="CONSOLE"/> </appender> <!-- 监控数据,启用监控功能时使用 --> <appender name="MONITOR_SQLLOG" class="com.xxx.xxxx.infrastructure.log4j.JDBCExtAppender"> <param name="driver" value="oracle.jdbc.driver.OracleDriver"/> <param name="URL" value="jdbc:oracle:thin:@10.200.5.200:1521:BOSS15TEST"/> <param name="User" value="jop"/> <param name="Password" value="jop"/> <param name="sql" value="insert into SYS_ACCTMONITOR(ID,STARTTIME, USETIME,PARENTFLOWNO,IP,CLIENT,OPERATOR,TARGETSYSTEM,TARGETMODULE,TARGETFUNCTION,TARGETOPERATION,PARAMLIST,RESULTSTATUS,RESULTCODE) values (SYS_ACCTMONITOR_SEQ.nextval,to_timestamp('@starttime@','yyyy-MM-dd hh24:mi:ss.ff'), @usetime@, '@parentflowno@','@ip@','@client@','@operator@','@targetsystem@','@targetmodule@','@targetfunction@','@targetoperation@','@paramlist@','@resultstatus@','@resultcode@')"/> </appender> <!-- 监控数据记录异步化,只能给监控 com.xxx.xxxx.monitor 使用,其他logger不得使用此 appender --> <appender name="ASYNC_MONITOR_SQLLOG" class="org.apache.log4j.AsyncAppender"> <param name="BufferSize" value="1024"/> <param name="LocationInfo" value="true"/> <appender-ref ref="MONITOR_SQLLOG"/> </appender> <category name="com.xxx.xxxx.monitor"> <!-- 监控需要特殊控制,输出到自己的appender --> <param name="additivity" value="false"/> <priority value="DEBUG" /> <appender-ref ref="ASYNC_MONITOR_SQLLOG" /> </category> <!-- Hibernate log,需要特殊控制,使用 TRACE级别 --> <category name="org.hibernate.SQL"> <param name="additivity" value="false"/> <priority value="TRACE" /> <appender-ref ref="ASYNC_BCSS_LOG" /> <!-- ASYNC_Hibernate_SQL --> </category> <category name="org.hibernate.type"> <param name="additivity" value="false"/> <priority value="WARN" /> <appender-ref ref="ASYNC_BCSS_LOG" /> <!-- ASYNC_Hibernate_SQL --> </category> <category name="org.hibernate.cache"> <param name="additivity" value="false"/> <priority value="WARN" /> <appender-ref ref="ASYNC_JOP_LOG" /> </category> <category name="com.googlecode.hibernate.memcached"> <!-- L2,query cache 分布式缓存, --> <param name="additivity" value="false"/> <priority value="WARN" /> <appender-ref ref="ASYNC_JOP_LOG" /> </category> <!-- 默认所有业务日志输出到文件 bcss.log, 异步输出; 其他特殊控制,如:缓存日志输出到jop.log --> <root> <priority value="INFO" /> <appender-ref ref="ASYNC_BCSS_LOG" /> <!-- 生产环境 ASYNC_BCSS_LOG --> </root> </log4j:configuration>
相关推荐
chw0 2020-11-04
sdaq 2020-07-26
MrLiar 2020-07-07
sdaq 2020-06-16
丨Fanny丨Cri 2020-06-13
CXC0 2020-06-08
MrLiar 2020-06-04
丨Fanny丨Cri 2020-06-03
丨Fanny丨Cri 2020-05-17
JavaWinner 2020-05-10
JavaWinner 2020-05-04
CXC0 2020-04-20
CXC0 2020-04-10
丨Fanny丨Cri 2020-02-18
MrLiar 2020-02-16
CXC0 2020-02-09