标签:console 错误 rop login app oracl sys 目的 legend
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
### 设置###
log4j.rootLogger = off
### 输出信息到控制抬 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
### 输出DEBUG 级别以上的日志到=D://logs/error.log ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D://logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
### 输出ERROR 级别以上的日志到=D://logs/error.log ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File =D://logs/error.log
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
############ 输出到数据库logginfo表############
log4j.appender.database.Threshold=info
#定义什么级别的错误将写入到数据库中
log4j.appender.database.BufferSize=1
#设置缓存大小,就是当有1条日志信息时才往数据库插一次
log4j.appender.database=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.database.driver=oracle.jdbc.OracleDriver
#设置要将日志插入到数据库的驱动
log4j.appender.database.URL=jdbc:oracle:thin:@119.23.211.14:1521:orcl
log4j.appender.database.user=Legend
log4j.appender.database.password=Legend
log4j.appender.database.sql=insert into loginfo (Class,Mothod,createTime,LogLevel,MSG) values ('%C','%M','%d{yyyy-MM-dd HH:mm:ss}','%p','%m')
log4j.appender.database.layout=org.apache.log4j.PatternLayout
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
</Console>
<RollingFile name="RollingFile" filename="log/test.log"
filepattern="${logPath}/%d{YYYYMMddHHmmss}-fargo.log">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
<DefaultRolloverStrategy max="20" />
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
将上面的两个文件放入到项目的src目录下面
标签:console 错误 rop login app oracl sys 目的 legend
原文地址:https://www.cnblogs.com/qichunlin/p/10475965.html