日期:2014-05-16 浏览次数:20413 次
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="log4jConsole" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{yyyy-MM-dd HH\:mm\:ss},%p,%m%n"/> </layout> </appender> <appender name="log4jJDBC" class="org.apache.log4j.jdbc.JDBCAppender"> <param name="BufferSize" value="10"/> <param name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> <param name="URL" value="jdbc:sqlserver://localhost:1433;databaseName=DB"/> <param name="user" value="sa"/> <param name="password" value=""/> <param name="sql" value="INSERT INTO [log] (rid,pcName,pcUser,pcIp,time,[table],sql) values ('%X{rid}','%X{pcUser}','%X{pcName}','%X{pcIp}','%d{yyyy-MM-dd HH\:mm\:ss}','%p','%m')"/> </appender> <logger name="java.sql.PreparedStatement"> <level value="debug"/> <!-- <appender-ref ref="log4jJDBC" /> --> <appender-ref ref="log4jConsole" /> </logger> </log4j:configuration>
自己改吧-_-
需要一个log4j.tdt,和xml一起放到目录下