通过Eclipse启动应用程序和服务器时未创建Tomcat日志 [英] Tomcat log is not created when the application and server are started through eclipse

查看:215
本文介绍了通过Eclipse启动应用程序和服务器时未创建Tomcat日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using slf4j with the following configuration

<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.变量无济于事.

If I start tomcat using startup.bat I can see the GO.log and the catalina.{date}.log get generated. If I start tomcat from Eclipse no luck. I tried defining CATALINA_HOME in my env. variables to no avail.

我收到此错误

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文件?

How can I start the Tomcat through Eclipse in a "correct" manner which would allow me to log to the GO.log file?

推荐答案

尽管指定了一个环境变量CATALINA_HOME,尽管给出了这些参数-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仍然找不到日志目录.

Despite specifying an env var CATALINA_HOME and despite giving the eclipse these args -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 still couldn't find the log directory.

因此,我在服务器配置的环境选项卡下创建了CATALINA_HOME变量.我给该变量赋了一个值C:\ apache-tomcat-7.0.47,然后就成功了.

So I created the CATALINA_HOME variable under the environments tabs of server configuration. I gave that variable a value C:\apache-tomcat-7.0.47 and that did the trick.

希望它对其他人有帮助.

Hope it helps other folks.

这篇关于通过Eclipse启动应用程序和服务器时未创建Tomcat日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆