Xml代码
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPElog4j:configurationSYSTEM"log4j.dtd">
<log4j:configurationxmlns:log4j="http://jakarta.apache.org/log4j/"debug="false">
<!--业务日志,生产环境使用。hekun-->
<appendername="BCSS_LOG"class="org.apache.log4j.DailyRollingFileAppender">
<paramname="File"value="log/bcss.log"/>
<paramname="Append"value="true"/>
<paramname="DatePattern"value="'.'yyyy-MM-dd-HH"/>
<layoutclass="org.apache.log4j.PatternLayout">
<paramname="ConversionPattern"value="%d%t[%-5p](%F,%L)-%m%n"/>
</layout>
</appender>
<!--JOP框架底层日志,分析框架问题时使用。hekun-->
<appendername="JOP_LOG"class="org.apache.log4j.DailyRollingFileAppender">
<paramname="File"value="log/jop.log"/>
<paramname="Append"value="true"/>
<paramname="DatePattern"value="'.'yyyy-MM-dd-HH"/>
<layoutclass="org.apache.log4j.PatternLayout">
<paramname="ConversionPattern"value="%d%t(%F,%L)-%m%n"/>
</layout>
</appender>
<!--控制台日志,开发阶段使用-->
<appendername="CONSOLE"class="org.apache.log4j.ConsoleAppender">
<paramname="Target"value="System.out"/>
<paramname="Threshold"value="DEBUG"/>
<layoutclass="org.apache.log4j.PatternLayout">
<paramname="ConversionPattern"value="%d%t[%-5p](%F,%L)-%m%n"/>
</layout>
</appender>
<!--默认的异步文件日志输出,生产环境都采用此appender-->
<appendername="ASYNC_BCSS_LOG"class="org.apache.log4j.AsyncAppender">
<paramname="BufferSize"value="256"/>
<paramname="LocationInfo"value="true"/>
<appender-refref="BCSS_LOG"/>
</appender>
<!--默认的异步文件日志输出,生产环境都采用此appender-->
<appendername="ASYNC_JOP_LOG"class="org.apache.log4j.AsyncAppender">
<paramname="BufferSize"value="512"/>
<paramname="LocationInfo"value="true"/>
<appender-refref="JOP_LOG"/>
</appender>
<!--console异步日志,开发环境都使用此appender,方便调试-->
<appendername="ASYNC_CONSOLE"class="org.apache.log4j.AsyncAppender">
<paramname="BufferSize"value="64"/>
<paramname="LocationInfo"value="true"/>
<appender-refref="CONSOLE"/>
</appender>
<!--监控数据,启用监控功能时使用-->
<appendername="MONITOR_SQLLOG"class="com.xxx.xxxx.infrastructure.log4j.JDBCExtAppender">
<paramname="driver"value="oracle.jdbc.driver.OracleDriver"/><paramname="URL"value="jdbc:oracle:thin:@10.200.5.200:1521:BOSS15TEST"/>
<paramname="User"value="jop"/>
<paramname="Password"value="jp"/>
<paramname="sql"value="insertintoSYS_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-ddhh24:mi:ss.ff'),@usetime@,'@parentflowno@','@ip@','@client@','@operator@','@targetsystem@','@targetmodule@','@targetfunction@','@targetoperation@','@paramlist@','@resultstatus@','@resultcode@')"/>
</appender>
<!--监控数据记录异步化,只能给监控com.xxx.xxxx.monitor使用,其他logger不得使此appender-->
<appendername="ASYNC_MONITOR_SQLLOG"class="org.apache.log4j.AsyncAppender">
<paramname="BufferSize"value="1024"/>
<paramname="LocationInfo"value="true"/>
<appender-refref="MONITOR_SQLLOG"/>
</appender>
<categoryname="com.xxx.xxxx.monitor"><!--监控需要特殊控制,输出到自己的appender-->
<paramname="additivity"value="false"/>
<priorityvalue="DEBUG"/>
<appender-refref="ASYNC_MONITOR_SQLLOG"/>
</category>
<!--Hibernatelog,需要特殊控制,使用TRACE级别-->
<categoryname="org.hibernate.SQL">
<paramname="additivity"value="false"/>
<priorityvalue="TRACE"/>
<appender-refref="ASYNC_BCSS_LOG"/><!--ASYNC_Hibernate_SQL-->
</category>
<categoryname="org.hibernate.type">
<paramname="additivity"value="false"/>
<priorityvalue="WARN"/>
<appender-refref="ASYNC_BCSS_LOG"/><!--ASYNC_Hibernate_SQL-->
</category>
<categoryname="org.hibernate.cache">
<paramname="additivity"value="false"/>
<priorityvalue="WARN"/>
<appender-refref="ASYNC_JOP_LOG"/>
</category>
<categoryname="com.googlecode.hibernate.memcached"><!--L2,querycache分布式缓存,-->
<paramname="additivity"value="false"/>
<priorityvalue="WARN"/>
<appender-refref="ASYNC_JOP_LOG"/>
</category>
<!--默认所有业务日志输出到文件bcss.log,异步输出;其他特殊控制,如:缓存日志输出到jop.log-->
<root>
<priorityvalue="INFO"/>
<appender-refref="ASYNC_BCSS_LOG"/><!--生产环境ASYNC_BCSS_LOG-->
</root>
</log4j:configuration>