[英]Tomcat log is not created when the application and server are started through eclipse
I'm using slf4j with the following configuration 我正在使用以下配置的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>
If I start tomcat using startup.bat I can see the GO.log and the catalina.{date}.log get generated. 如果我使用startup.bat启动tomcat,则可以看到GO.log和catalina。{date} .log生成。 If I start tomcat from Eclipse no luck. 如果我从Eclipse启动tomcat,那就没有运气了。 I tried defining CATALINA_HOME in my env. 我尝试在环境中定义CATALINA_HOME。 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? 如何以“正确”的方式通过Eclipse启动Tomcat,这将允许我登录到GO.log文件?
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. 尽管指定了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"
var 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仍然找不到日志目录。
So I created the CATALINA_HOME variable under the environments tabs of server configuration. 因此,我在服务器配置的环境选项卡下创建了CATALINA_HOME变量。 I gave that variable a value C:\\apache-tomcat-7.0.47 and that did the trick. 我给该变量赋了一个值C:\\ apache-tomcat-7.0.47,然后就成功了。
Hope it helps other folks. 希望它对其他人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.