Java Logging - 我的日志文件在哪里? [英] Java Logging - where is my log file?

查看:246
本文介绍了Java Logging - 我的日志文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到我的日志文件。

I'm having trouble finding my log files.

我在Windows XP上的Eclipse 3.7.1中使用Java Logging - java.util.logging 。我的 logging.properties 文件的相关行是:

I'm using Java Logging - java.util.logging - in Eclipse 3.7.1 on Windows XP. The relevant lines of my logging.properties file are:

handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

据我所知,执行这两行之后:

As far as I can figure out, after I execute these two lines:

Logger logger = Logger.getLogger("test"); 
logger.logp(Level.INFO, "myClass", "myMethod", "Alcatraz"); 

我的日志文件应该在 C:\Documents and Settings \ [我的Windows ID] \ javaX.log 其中 X 是一个整数。

my log file should be in C:\Documents and Settings\[My Windows ID]\javaX.log where X is an integer.

我在该目录中有5个不同的 java.log 文件, java0.log 通过 java4.log ,但它们都不包含我的日志记录,甚至包含今天日期的记录。我做了一些谷歌搜索,发现跟踪和记录这意味着我的日志应该位于不同的位置, c:\Documents and Settings \ [我的Windows ID] \ Application Data \ Sun \ Java \ Depation \\ \\log 。那里有一个文件,名为 plugin5581819941091650582.log ,但它基本上是空的:

I have 5 different java.log files in that directory, java0.log through java4.log, but none of them contain my log record or even a record with today's date on it. I did some googling and found Tracing and Logging which implies that my logs should be at a different location, c:\Documents and Settings\[My Windows ID]\Application Data\Sun\Java\Deployment\log. There is one file there, named plugin5581819941091650582.log, but it is essentially empty:

<?xml version="1.0" encoding="windows-1252" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
</log>

它的创建日期是上周。 (我不确定是什么过程创建的;我当然没有明确地创建它。)

Its creation date is last week. (I'm not sure what process created it; I certainly didn't create it explicitly.)

那么我的日志文件在哪里呢?我无法想到其他任何地方。

So where is my log file then? I can't think of anywhere else to look.

此外,是否有人知道对 logging.properties 的更改何时生效?如果我更改了日志级别或 FileHandler.pattern ,那么在我的程序看到更改之前会发生什么?仅仅保存 logging.properties 中的更改显然是不够的。我需要重启Eclipse吗?或重启电脑?只是好奇。对我来说,找到我的日志文件实际位置并不是什么大不了的事。

Also, does anyone know when changes to logging.properties take effect? If I changed the log level or the FileHandler.pattern, what would have to happen before my program saw the changes? Simply saving the changes in logging.properties is clearly not enough. Will I need to restart Eclipse? Or reboot the computer? Just curious. That's not nearly as big a deal to me as finding out where my log file actually is.

推荐答案

您的 logging.properties 文件位于何处?它应该在类路径的根目录中可用。作为完整性检查,以下代码打印是什么?

Where is your logging.properties file located? It should be available in the root of the classpath. As a sanity check, what does the following code print?

System.out.println(getClass().getClassLoader().getResource("logging.properties"));

如果代码位于 static 上下文中,使用

If the code is in a static context, use

System.out.println(ClassName.class.getClassLoader().getResource("logging.properties"));

这篇关于Java Logging - 我的日志文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆