log4j指向错误的反斜杠日志路径

时间:2018-11-01 09:06:41

标签: java logging log4j

我试图在WebLogic 9上部署应用程序,并且控制台日志不断抛出此错误:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: logs\sd.log (The system cannot find the path specified)
    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:272)
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:151)
    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.sherwin.sd.web.filter.RedirectFilter.logger(RedirectFilter.java:253)
    at com.sherwin.sd.web.filter.RedirectFilter.init(RedirectFilter.java:113)
    at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterManager.java:309)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.FilterManager.loadFilter(FilterManager.java:88)
    at weblogic.servlet.internal.FilterManager.preloadFilters(FilterManager.java:56)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1618)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2761)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:889)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:333)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:26)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:181)
    at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:358)
    at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:52)
    at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:186)
    at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
    at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:254)
    at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:239)
    at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
    at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
    at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
    at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
    at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
log4j:ERROR Either File or DatePattern options are not set for appender [R].
  

java.io.FileNotFoundException:logs \ sd.log(系统找不到   指定的路径)

我可以看到它指向反斜杠路径,而不是正确的正斜杠。之后,我检查了log4j.properties并确保logs / sd.log的路径正确,文件夹和日志文件也位于其中:

https://jansson.readthedocs.io/en/2.8/apiref.html#c.json_dumps

但是,由于反斜杠,它仍然使我找不到路径错误。可能出什么问题了?

1 个答案:

答案 0 :(得分:0)

我很累给sd.log一个绝对路径(/logs/sd.log),但它不起作用。最后,我只是将 log4j.appender.R.File 路径更改为sd.log,而FileNotFoundException错误消失了。