<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false">
<appender name="ROLLING" class="org.apache.log4j.RollingFileAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
</layout>
<param name="File" value="/var/log/4j/log_gsX.log"/>
<param name="MaxFileSize" value="50MB"/>
<param name="MaxBackupIndex" value="9"/>
</appender>
<appender name="DAILY_LUA" class="org.apache.log4j.DailyRollingFileAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
</layout>
<param name="File" value="/var/log/4j/log_gsX_lua.log"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
</layout>
<param name="Threshold" value="info"/>
</appender>
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="100000"/>
<param name="Blocking" value="false"/>
<appender-ref ref="ROLLING"/>
<appender-ref ref="CONSOLE"/>
</appender>
<appender name="ASYNC_LUA" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="100000"/>
<param name="Blocking" value="false"/>
<appender-ref ref="DAILY_LUA"/>
</appender>
<root>
<level value="info"/>
<appender-ref ref="ASYNC" />
</root>
<logger name="Lua">
<level value="info"/>
<appender-ref ref="ASYNC_LUA" />
</logger>
<logger name="main">
<level value="info"/>
</logger>
<logger name="THSever">
<level value="debug"/>
</logger>
</log4j:configuration>
ASYNC异步输出到ROLLING和CONSOLE。
另外,Lua日志异步输出为每天一个的独立日志。
默认仅输出INFO日志,THServer日志类输出DEBUG日志。
CONSOLE屏蔽DEBUG日志。
每个服务器使用相类似的配置,仅输出文件名不同。可用如下Shell脚本生成各个配置文件:
for i in {2..32}do sed 's/gsX/gs'${i}'/g' log4j_gsX.xml > log4j_gs${i}.xmldone