[英]Some issues with java.util.logging.Logger
I have the following example code : 我有以下示例代码:
import java.util.logging.Logger;
public class LoggingExample {
private static final Logger LOGGER = Logger.getLogger(
Thread.currentThread().getStackTrace()[0].getClassName() );
public static void main(String[] args) {
LOGGER.setLevel(Level.ALL);
LOGGER.info("Logging an INFO-level message");
LOGGER.fine("Logging an INFO-level message2");
}
}
With the output to console of: 随着输出到控制台:
05/06/2014 12:07:09 ztesting.Loger.LoggingExample main
INFO: Logging an INFO-level message
And I have several question: 我有几个问题:
PS I m using netbeans 6.9 PS我正在使用netbeans 6.9
ALSO tried using the following links and it got me no where 还尝试使用以下链接,它让我无处可去
Is there any way to remove the information line from java.util.logging.Logger output? 有什么方法可以从java.util.logging.Logger输出中删除信息行?
How do I get java logging output to appear on a single line? 如何使Java日志输出显示在一行上?
Thanks for any help .. 谢谢你的帮助 ..
Most of your questions are answered in different tutorials available for java.util.logging
. 您的大多数问题在
java.util.logging
可用的不同教程中得到了回答。 One example here 这里的一个例子
You should also read the javadoc . 您还应该阅读javadoc 。
"Can I not display the first line "05/06/2014 12:07:09 ztesting.Loger.LoggingExample main"
Yes, using Formatters 是的,使用格式化程序
"Can I block the output to console completely, meaning I would only set output to a log file."
Yes, set the log level, filter or handler in a configuration file 是的,在配置文件中设置日志级别,过滤器或处理程序
"The entire output is in red, can I set the output to be in different colors according to the level?"
This is specific to Netbeans which I don't personally use so I can't answer that. 这是针对我个人不使用的Netbeans的,因此我无法回答。
Personally I prefer SLF4J with Logback over JUL... 我个人更喜欢带Logback的 SLF4J而不是 JUL ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.