java 如何写入Tomcat日志文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2445043/
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 to write to Tomcat log files
提问by Ankur
What is the easiest way to print out something in a Tomcat Log file.
在 Tomcat 日志文件中打印内容的最简单方法是什么。
I was under the impression that System.out.println() would print to one of the log files.
我的印象是 System.out.println() 会打印到日志文件之一。
I just want to print out the value of a string, so the simplest solution would be best. If there is no simple/trivial solution I guess I will use Log4J
我只想打印出一个字符串的值,所以最简单的解决方案是最好的。如果没有简单/微不足道的解决方案,我想我会使用 Log4J
EDIT: I used Log4J as follows:
编辑:我使用 Log4J 如下:
As a class variable I declared:
作为一个类变量,我声明:
static Logger log = Logger.getLogger("myClass");
静态记录器日志 = Logger.getLogger("myClass");
I then placed:
然后我放置:
log.warn("Upload directory: "+destDirectory);
However now I want to read the value of destDirectory, and cannot see it in any of the Tomcat logs?
但是现在我想读取 destDirectory 的值,并且在任何 Tomcat 日志中都看不到它?
回答by Holograham
http://tomcat.apache.org/tomcat-6.0-doc/logging.html
http://tomcat.apache.org/tomcat-6.0-doc/logging.html
Seems to explain what your looking for.
似乎解释了你在寻找什么。

