我的log4j有2个问题,也许一个导致另一个。
log4j:ERROR找不到键log4j.appender.rollingFile的值
log4j.properties文件:
log4j.rootLogger=INFO, S, rollingFile, sql
log4j.appender.S =org.apache.log4j.ConsoleAppender
log4j.appender.S.layout =org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss,SSS} %c{1} [%p] %m%n
log4j.appender.rollingFile = org.apache.log4j.DailyRollingFileAppender
log4j.appender.rollingFile.File =C:\\log.log
log4j.appender.rollingFile.Append = true
log4j.appender.rollingFile.MaxFileSize=2000KB
log4j.appender.rollingFile.MaxBackupIndex=19
log4j.appender.rollingFile.Threshold = ALL
log4j.appender.rollingFile.DatePattern = '.'yyy-MM-dd
log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
log4j.appender.rollingFile.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss,SSS} %c{1} [%p] %m%n
log4j.appender.sql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.sql.URL=jdbc:jtds:sqlserver://devsql/DBName
log4j.appender.sql.driver=net.sourceforge.jtds.jdbc.Driver
log4j.appender.sql.user=user_name
log4j.appender.sql.password=password
log4j.appender.sql.sql=INSERT INTO Log (logTypeId,logServiceId,hostId,logDateTime,logTitle,logModule,logDesc,logLineNumber,logStackTrace,userId) VALUES('%p','Project','172.0.12.123',now(),'%c{1}','%c{2}',N'%m','%L','%throwable{200}','%X{userId}')
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
我的课是:
import org.apache.log4j.Logger;
public class BasicApi {
private static final Logger LOG = Logger.getLogger(BasicApi.class.getName());
public ResponseEntity<String> runApi(InputBo input) {
LOG.info("!!!!!!!!!!!!!trying1!!!!!!!!!!!!!!");
LOG.debug("!!!!!!!!!!!!!trying2!!!!!!!!!!!!!!");
}
}
错误是:
log4j:ERROR找不到键log4j.appender.rollingFile的值 log4j:ERROR无法实例化名为“ rollingFile”的附加程序。
重要的事情:此代码在maven jar项目下,另一个项目将其添加为依赖项。 您能帮我解决这段代码有什么问题吗?谢谢