【问题标题】:Tomcat log is not created when the application and server are started through eclipse通过eclipse启动应用程序和服务器时不创建tomcat日志
【发布时间】:2014-10-14 00:34:46
【问题描述】:

我正在使用具有以下配置的 slf4j

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>${CATALINA_HOME}/logs/GO.log</file>
        <encoder>
            <pattern>%date %-5level [%thread] - [%logger] - %msg%n</pattern>
        </encoder>
    </appender>

 <root level="DEBUG">
        <appender-ref ref="stdout"/>
        <appender-ref ref="FILE"/>
 </root>

如果我使用 startup.bat 启动 tomcat,我可以看到 GO.log 和 catalina.{date}.log 生成。 如果我从 Eclipse 启动 tomcat 就没有运气了。 我尝试在我的环境中定义 CATALINA_HOME。变量无济于事。

我收到此错误

14:26:54,179 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - openFile(CATALINA_HOME_IS_UNDEFINED/logs/GO.log,true) call failed. java.io.FileNotFoundException: CATALINA_HOME_IS_UNDEFINED\logs\GLOBE_ONE.log (The system cannot find the path specified)
      at java.io.FileNotFoundException: CATALINA_HOME_IS_UNDEFINED\logs\GO.log (The system cannot find the path specified)
      at    at java.io.FileOutputStream.open(Native Method)
      at    at java.io.FileOutputStream.<init>(FileOutputStream.java:206)

如何以“正确”的方式通过 Eclipse 启动 Tomcat,从而允许我登录到 GO.log 文件?

【问题讨论】:

    标签: java eclipse tomcat logging slf4j


    【解决方案1】:

    尽管指定了一个环境变量 CATALINA_HOME 并且尽管给了 Eclipse 这些参数 -Dcatalina.base="C:\apache-tomcat-7.0.47" -Dcatalina.home="C:\apache-tomcat-7.0.47" -Dwtp.deploy="C:\apache-tomcat-7.0.47\webapps" -Djava.endorsed.dirs="C:\apache-tomcat-7.0.47\endorsed" Eclipse 仍然找不到日志目录。

    所以我在服务器配置的环境选项卡下创建了 CATALINA_HOME 变量。我给那个变量一个值 C:\apache-tomcat-7.0.47 就成功了。

    希望它可以帮助其他人。

    【讨论】:

    • 嗨,alex,你能告诉我你在哪里做这个配置吗?谢谢
    • 这个设置对我不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 2010-11-25
    • 1970-01-01
    • 2014-07-14
    • 2020-04-12
    相关资源
    最近更新 更多