Tomcat log is not created when the application and server are started through eclipse

回眸只為那壹抹淺笑 提交于 2019-12-12 04:58:21

问题


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>

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.

I get this error

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)

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/26350970/tomcat-log-is-not-created-when-the-application-and-server-are-started-through-ec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!