log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: log\spring.log (系统找不到指定的路径。)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:273)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:152)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:206)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:247)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:123)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:87)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:645)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:603)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:500)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:406)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:432)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
at org.apache.log4j.Logger.getLogger(Logger.java:94)
at com.juguo.niuniusearch.dao.RelevWordDAO.<init>(RelevWordDAO.java:22)
at com.juguo.niuniusearch.service.RelevWordService.<init>(RelevWordService.java:15)
at com.juguo.niuniusearch.servlet.Autocomplete.getDB(Autocomplete.java:61)
at com.juguo.niuniusearch.servlet.Autocomplete.doPost(Autocomplete.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
一个web项目做日志时出现的错误
由log4j.appender.DailyRollingFile.File=log/spring.log,可以看出我们要新建一个log文件,我在myeclipse中项目底下,也确实建了log,但是还是找不到路径。
原因,启动Tomcat时,项目是在Tomcat路径下运行,所以我们要找到Tomcat的安装路径,然后在bin文件中新建一个log文件,就可以了。
下面是我log4j.properties内容
#log4j.rootLogger=FATAL ERROR WARN INFO DEBUG
log4j.rootLogger=DEBUG,consoleFile,DailyRollingFile
log4j.appender.consoleFile=org.apache.log4j.ConsoleAppender
log4j.appender.consoleFile.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleFile.layout.ConversionPattern=[%-5p] %t %d %37c %3x - %m%n
log4j.appender.consoleFile.Threshold=INFO
log4j.appender.consoleFile.ImmediateFlush=true
log4j.appender.consoleFile.Target=System.out
log4j.appender.DailyRollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DailyRollingFile.File=log/spring.log
log4j.appender.DailyRollingFile.DatePattern='.'yyyy-MM-dd
log4j.appender.DailyRollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DailyRollingFile.layout.ConversionPattern=%d %-5p %37c - %m%n
log4j.appender.DailyRollingFile.Threshold=DEBUG
分享到:
相关推荐
解决log4j:ERROR Failed to rename, win系统占用文件无法改名字的问题
log4j:ERROR Failed to rename
log4j:ERROR Failed to rename错误; 网上查找了下原因,大概意思是日志文件始终被占有,所以当log4j对日志文件进行rename时,就发生了Failed to rename错误 。要修改log4j的源码,附件是我修改好后的,方便大家...
log4j:ERROR Failed to rename错误解决办法 http://www.blogjava.net/DreamAngel/archive/2011/11/10/363400.html
log4j:ERROR Failed to rename错误解决办法,修改源码里的DailyRollingFileAppender类,用此jar包就不会再出现ERROR Failed to rename的错误了
包括修改后的[color=darkred]org.apache.log4j.DailyRollingFileAppender[/color]类的源代码和已编译好的文件. 请用DailyRollingFileAppender.class替换log4j-1.2.15.jar包里相应的类. 博文链接:...
log4j.appender.file.Append=true log4j.appender.file.Threshold=INFO log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %...
NULL 博文链接:https://wait7758521.iteye.com/blog/1933964
10:35:09,498 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(null,true) call failed. java.io.FileNotFoundException: logs/bandwidth.log.2019-04-25.log (Permission ...
log4j.appender.ROLLING_FILE.Threshold=ERROR log4j.appender.ROLLING_FILE.File=rolling.log //文件位置,也可以用变量${java.home}、rolling.log log4j.appender.ROLLING_FILE.Append=true //true:添加 false:覆盖...
- `log4j.appender.ROLLING_FILE.Threshold=ERROR`:设置此appender只记录错误级别的日志。 - `log4j.appender.ROLLING_FILE.File=rolling.log`:指定回滚日志文件名称为`rolling.log`。 - `log4j.appender.ROLLING_...
log4j.appender.file.Append=true log4j.appender.file.Threshold=DEBUG log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p ...
log4j.appender.ERROR_FILE=org.apache.log4j.DailyRollingFileAppender log4j.appender.ERROR_FILE.File=logs/error.log log4j.appender.ERROR_FILE.DatePattern='.'yyyy-MM-dd log4j.appender.ERROR_FILE.layout=...
log4j.appender.FILE.ImmediateFlush=true log4j.appender.FILE.Threshold=DEBUG log4j.appender.FILE.Append=true log4j.appender.FILE.DatePattern='.'yyyy-MM-dd log4j.appender.FILE.layout=org.apache.log4j....
- **定义日志文件Appender**:如`log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender`,每天创建新的日志文件。 - **文件Appender属性**:`log4j.appender.FILE.File=logs/app.log`,指定日志文件的...
app.Visible = true; // 构建结构体参数 MWStructArray structParam = new MWStructArray("param", "name", "value"); structParam.SetField("name", 1, "input"); structParam.SetField("value", 1, new ...
log4j.appender.FILE.ImmediateFlush=true log4j.appender.FILE.Threshold=DEBUG log4j.appender.FILE.Append=true log4j.appender.FILE.DatePattern='.'yyyy-MM-dd'.log' # 每天生成一个新的日志文件 # 设置日志...
log4j.appender.file.Threshold=ERROR log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[%p][%d{yy-MM-dd}][%c]%m%n ``` 这个配置文件定义了两个日志...