简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM