apache Tomcat server.xml 中的调试级别(0-99)如何影响速度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/102058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does debug level (0-99) in the Tomcat server.xml affect speed?
提问by dacracot
The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug attribute for nearly every major component. The debug attribute is more or less verbose depending upon the number you give it, zero being least and 99 being most verbose. How does the debug level affect Tomcat's speed when servicing large numbers of users? I assume zero is fast and 99 is relatively slower, but is this true. If there are no errors being thrown, does it matter?
控制 Apache Tomcat 的 servlet 容器启动的 server.xml 包含几乎每个主要组件的调试属性。debug 属性或多或少的冗长取决于您给它的数字,0 表示最少,99 表示最详细。服务大量用户时,调试级别如何影响Tomcat的速度?我假设 0 很快,99 相对较慢,但这是真的。如果没有抛出错误,这有关系吗?
采纳答案by entzik
Extensive logging takes a significant amount of time. This is why it is so important to put
大量的日志记录需要大量的时间。这就是为什么放置如此重要的原因
if (log.isDebugEnabled())
log.debug(bla_bla_bla);
so I would say that seting your production server to being verbose would seriously affect performance. I assume it's a production server you're talking about since you say it must service a large number of users.
所以我会说将您的生产服务器设置为冗长会严重影响性能。我假设它是您正在谈论的生产服务器,因为您说它必须为大量用户提供服务。
回答by Aleksandar Dimitrov
Logging is not only responsible for giving you errors, but also for tracking of what's going on. In some cases, code cannot run inside a debugger, then logging is your only option.
日志记录不仅负责为您提供错误,还负责跟踪正在发生的事情。在某些情况下,代码无法在调试器中运行,因此日志记录是您唯一的选择。
This is why logging output can be extremely verbose. And I really meanthat. I remember setting Catalina's loglevel to TRACE once and ended up with a several megabyte logfile. That was beforethe server received any hits at all. It was a huge performance hog. Countable in several seconds.
这就是日志输出可能非常冗长的原因。我真的是这个意思。我记得曾经将 Catalina 的日志级别设置为 TRACE,最终得到了几兆字节的日志文件。那是在服务器根本没有收到任何点击之前。这是一个巨大的性能猪。在几秒钟内计数。
If you don't need logging for Tomcat itself, don't activate it on any of its components. You will typically only want to tinker with Tomcat's loglevel if you suspect a bug in either your setup or Tomcat itself.
如果您不需要 Tomcat 本身的日志记录,请不要在其任何组件上激活它。如果您怀疑您的设置或 Tomcat 本身存在错误,您通常只想修改 Tomcat 的日志级别。
For your own applications, measure the logging cost using a profiler or just some stress testing. Whatever your results, I would recommend against running an application with a high loglevel setting in a production environment. My current project dumps about a megabyte per requestat TRACE setting, only about three to four lines on INFO and nothing on WARNING (iff everything goes well :-). I recommend not more than the most necessary logging. Your app should really just report startup, shutdown and failure, and - at most - one line per request.
对于您自己的应用程序,使用分析器或仅进行一些压力测试来测量日志记录成本。无论结果如何,我都建议不要在生产环境中运行具有高日志级别设置的应用程序。我当前的项目在 TRACE 设置中每个请求转储大约 1 兆字节,在 INFO 上只有大约三到四行,在 WARNING 上没有任何内容(如果一切顺利:-)。我建议不要超过最必要的日志记录。您的应用程序实际上应该只报告启动、关闭和失败,并且 - 最多 - 每个请求一行。

