日期:2014-05-16  浏览次数:20557 次

log4j 日志信息存入数据库(配置文件)

# This is the configuring for logging displayed in the Application Server  
log4j.rootCategory=DEBUG,logfile,stdout  
  
log4j.logger.SYSTEM = INFO,JDBC  
log4j.logger.OPERATION = INFO,JDBC2  
  
#stdout configure  
log4j.appender.stdout=org.apache.log4j.ConsoleAppender  
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  
log4j.appender.stdout.layout.ConversionPattern= %d %p [%c] - <%m>%n  
  
#logfile configure  
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=../logs/moca_stm_stm.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern= %d{yyyy MM dd HH:mm:ss} %p [%c] - <%m>%n
  
#JDBC configure  
log4j.appender.JDBC.Threshold=INFO  
log4j.appender.JDBC=org.apache.log4j.jdbc.JDBCAppender   
log4j.appender.JDBC.driver=oracle.jdbc.driver.OracleDriver  
log4j.appender.JDBC.URL=jdbc:oracle:thin:@127.0.0.1:1521:ORCL  
log4j.appender.JDBC.user=userName  
log4j.appender.JDBC.password=userPassword  
log4j.appender.JDBC.layout=org.apache.log4j.PatternLayout  
log4j.appender.JDBC.sql=INSERT INTO SYS_LOG(USERID,LOGTIME,LOGLEVEL,LOCATION,MESSAGE)VALUES('%X{userId}','%d{yyyy-MM-dd HH:mm:ss}','%p','%l','%m')  
  
  
log4j.appender.JDBC2.Threshold=INFO  
log4j.appender.JDBC2=org.apache.log4j.jdbc.JDBCAppender   
log4j.appender.JDBC2.driver=oracle.jdbc.driver.OracleDriver  
log4j.appender.JDBC2.URL=jdbc:oracle:thin:@127.0.0.1:1521:ORCL 
log4j.appender.JDBC2.user=userName  
log4j.appender.JDBC2.password=userPassword  
log4j.appender.JDBC2.layout=org.apache.log4j.PatternLayout  
log4j.appender.JDBC2.sql=INSERT INTO SYS_LOG_2(USERID,LOGTIME,LOGLEVEL,LOCATION,MESSAGE)VALUES('%X{userId}','%d{yyyy-MM-dd HH:mm:ss}','%p','%l','%m')  
?