为什么我收到此FileNotFoundException以及如何解决它?

时间:2016-05-23 18:45:18

标签: amazon-web-services logging log4j tomcat7

我正在尝试在我的tomcat服务器上实现Log4J日志记录(我们在本地环境中实现了这一点,并且我准备将我们的服务迁移到AWS)。我跟随instructions found in the Tomcat7 documentation并将所有内容都放在合适的位置。当我尝试启动Tomcat时,我在日志中收到FileNotFound异常,应用程序无法启动。

Configuration error
java.io.FileNotFoundException: /usr/share/tomcat7/conf/logging.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at java.io.FileInputStream.<init>(FileInputStream.java:101)
        at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:466)
        at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:311)
        at java.util.logging.LogManager$2.run(LogManager.java:320)
        at java.util.logging.LogManager$2.run(LogManager.java:318)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:318)
        at java.util.logging.LogManager.getLogManager(LogManager.java:300)
        at java.util.logging.Logger.<init>(Logger.java:265)
        at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1468)
        at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1466)
        at java.util.logging.LogManager$1.run(LogManager.java:204)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.<clinit>(LogManager.java:181)
        at java.util.logging.Logger.demandLogger(Logger.java:339)
        at java.util.logging.Logger.getLogger(Logger.java:393)
        at org.apache.juli.logging.impl.Jdk14Logger.getLogger(Jdk14Logger.java:164)
        at org.apache.juli.logging.impl.Jdk14Logger.<init>(Jdk14Logger.java:55)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.apache.juli.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
        at org.apache.juli.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
        at org.apache.juli.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
        at org.apache.juli.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
        at org.apache.juli.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
        at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:657)
        at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:49)

我怀疑这是因为我们的Tomcat7配置存在一些非标准的问题,但AWS上的初始设置是由我不再可用的顾问执行的。我在哪里可以查看,我应该检查什么来纠正这个问题?

好的答案不应该指示我将logging.properties文件放在/usr/share/tomcat7/conf/中,因为这不是我现有配置的工作原理(我在那里没有这个问题)和tomcat7文档明确告诉用户从logging.properties 中删除../conf/,除非有一些警告需要它在tomcat文档中没有表达。

1 个答案:

答案 0 :(得分:3)

似乎问题与tomcat7 bash shell脚本(由上述顾问编写或更新)有关。此脚本已硬编码以检查Java选项(logging.properties)中的-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties"文件。

从tomcat7脚本中删除此行已更正此问题。