Tomcat 中未捕获的异常打印到 localhost.[date].log 而不是 catalina.out

发布于 2024-09-28 20:52:04 字数 321 浏览 5 评论 0原文

我正在运行 tomcat 6.0.20(使用 spring,如果这很重要),并且似乎无法从代码中抛出的未捕获异常中获取堆栈跟踪以打印到 catalina.out。

我正在尝试模仿您在 eclipse 控制台中看到的输出。当我在生产服务器上部署战争并启动 tomcat 时,大部分输出都会转到 catalina.out,但我自己的代码中引发的异常的堆栈跟踪会转到 tomcat/logs/localhost.[date].log。

我怎样才能将所有相关日志记录到一个文件中(类似于 Eclipse 的控制台)?

我只需运行 tomcat/bin/startup.sh 即可启动服务器

I'm running tomcat 6.0.20 (with spring, if that matters) and can't seem to get stack traces from uncaught exceptions thrown from within my code to print to catalina.out.

I'm trying to mimic the output that you see in the eclipse console. When I deploy a war on a production server and start tomcat, most of the output goes to catalina.out, but stack traces from exceptions thrown within my own code goes to tomcat/logs/localhost.[date].log.

How can I get all of the relevant logging to go to one file (similar to eclipse's console)?

I'm starting the server by simply running tomcat/bin/startup.sh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我纯我任性 2024-10-05 20:52:04

编辑 TOMCAT_HOME/conf/logging.properties 默认情况下,

catalina 引擎日志会记录到 catalina.log,本地主机日志记录到 localhost.log

,如下所示

1catalina.org.apache.juli.FileHandler.level = ALL
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = ALL
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

选择并编辑 .prefix 指向您想要的那个。

更新
catalina.outcatalina.sh 启动脚本中显式引用,如下所示(但不在相应的 bat 文件中) - 这就是为什么我看不到 .out 文件在 Windows 上,但仅在 *nix 系统上

"$CATALINA_BASE"/logs/catalina.out 2>&1

个人 我更喜欢将 Catalina 引擎日志与我的应用程序日志分开

Edit TOMCAT_HOME/conf/logging.properties

The default would have the catalina engine log to catalina.log and the localhost logging to localhost.log

like below

1catalina.org.apache.juli.FileHandler.level = ALL
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = ALL
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

Take your pick and edit .prefix to point to the one you want.

Update
catalina.out is explicitly referenced as shown below in the catalina.sh start script (but not in the corresponsing bat files) - which is why I dont see the .out file on windows but only on *nix systems

"$CATALINA_BASE"/logs/catalina.out 2>&1

Personally I prefer the Catalina engine logs being separate from my application logs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文