-
Enhancement
-
Resolution: Unresolved
-
P4
-
1.4.1
-
Cause Known
-
x86
-
windows_xp
Name: rmT116609 Date: 04/22/2004
A DESCRIPTION OF THE REQUEST :
I am presently unable to find any way to determine the names of the actual files to which a logger in the java.util.logging.* classes is writing. I have posted a question to this effect to the comp.lang.java.programmer newsgroup and got no satisfactory answer on how to obtain this information.
I would really like to see a method or methods added to the java.util.logging.* package so that, given a specific logger, I can determine the exact file names and paths of all files that will be written by FileHandlers associated with that logger.
JUSTIFICATION :
It's all too common to see an error handler simply advise the user who encounters an error of some kind to be told to "Consult the log for more information." yet not be given any idea whatsoever where the log actually is. It's not all that rare for system administrators saddled with a new purchased system to not know where that system writes its logs either.
In my opinion, a good solution to both problems is for the developer of that system to be able to tell the user and/or administrator exactly where to find the log(s) that contain the details about the event that was just logged. This will enable the problem to be solved considerably faster without the need for the user to first contact a system administrator who in turn has to spend hours researching the Logging API and articles about logging in order to determine where the log is actually written.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Given a situation in a class encounters a problem,displaying information about that error via a GUI is a common tactic.
As someone writing such a GUI, I would like to be able to advise the user of a few facts about the event that was just logged and also advise them that additional information about the event were logged in such-and-such specific files, e.g. d:\eclipse\java0.log and/or e:\application\rte0.log.
I've already written most of such a GUI but, unless I'm missing something, there doesn't seem to be a way to determine the names of the actual files being written by the loggers in the hierarchy given only a reference to the application-specific logger.
In my opinion, it should only be necessary to pass an error handler a reference to the application-specific logger: anything else that is needed should be deducible from that reference. Therefore, given a class called foo.bar, which is logging to a logger also called "foo.bar" and which has a FileHandler associated with it, I want to pass the error handler class a reference to the application-specific logger, like this:
package foo;
public class bar {
...
public oops() {
new ErrorHandler(<other parms>, logger);
} //end oops()
} //end class bar
Then, in the ErrorHandler class, I'd like to be able to interrogate the logger reference somehow so that it will tell me the name of the file to which the application-specific logger is writing its messages. A nice bonus would be to determine the names of the files written by any other FileHandlers in the logger hierarchy besides the application-specific one, such as the one associated with the root logger. The code for that interrogation might look something like this:
package common;
public class ErrorHandler extends JDialog {
public ErrorHandler(<other parameters>, Logger logger) {
/* Display other facts about error, like class name and method name,
which would be passed in <other parameters>, in JTextFields and put
them on the JDialog. */
/* Interrogate the logger to determine the name of the log file to which the application-specific logger is writing. */
String logFileName = logger.getFileName();
String logFilePath = logger.getFilePath();
/* Optional: determine the other FileHandlers in the logger hierarchy and then determine the names of the files to which they are writing. */
???
/* Concatenate the path and file name for each log file and display the concatenated names in a JLabel. This content might look like this:
For more information about this error, consult the following log files:
c:\Corporate\master.log
d:\Application\foo.log
*/
???
}
}
(Incident Review ID: 234250)
======================================================================
A DESCRIPTION OF THE REQUEST :
I am presently unable to find any way to determine the names of the actual files to which a logger in the java.util.logging.* classes is writing. I have posted a question to this effect to the comp.lang.java.programmer newsgroup and got no satisfactory answer on how to obtain this information.
I would really like to see a method or methods added to the java.util.logging.* package so that, given a specific logger, I can determine the exact file names and paths of all files that will be written by FileHandlers associated with that logger.
JUSTIFICATION :
It's all too common to see an error handler simply advise the user who encounters an error of some kind to be told to "Consult the log for more information." yet not be given any idea whatsoever where the log actually is. It's not all that rare for system administrators saddled with a new purchased system to not know where that system writes its logs either.
In my opinion, a good solution to both problems is for the developer of that system to be able to tell the user and/or administrator exactly where to find the log(s) that contain the details about the event that was just logged. This will enable the problem to be solved considerably faster without the need for the user to first contact a system administrator who in turn has to spend hours researching the Logging API and articles about logging in order to determine where the log is actually written.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Given a situation in a class encounters a problem,displaying information about that error via a GUI is a common tactic.
As someone writing such a GUI, I would like to be able to advise the user of a few facts about the event that was just logged and also advise them that additional information about the event were logged in such-and-such specific files, e.g. d:\eclipse\java0.log and/or e:\application\rte0.log.
I've already written most of such a GUI but, unless I'm missing something, there doesn't seem to be a way to determine the names of the actual files being written by the loggers in the hierarchy given only a reference to the application-specific logger.
In my opinion, it should only be necessary to pass an error handler a reference to the application-specific logger: anything else that is needed should be deducible from that reference. Therefore, given a class called foo.bar, which is logging to a logger also called "foo.bar" and which has a FileHandler associated with it, I want to pass the error handler class a reference to the application-specific logger, like this:
package foo;
public class bar {
...
public oops() {
new ErrorHandler(<other parms>, logger);
} //end oops()
} //end class bar
Then, in the ErrorHandler class, I'd like to be able to interrogate the logger reference somehow so that it will tell me the name of the file to which the application-specific logger is writing its messages. A nice bonus would be to determine the names of the files written by any other FileHandlers in the logger hierarchy besides the application-specific one, such as the one associated with the root logger. The code for that interrogation might look something like this:
package common;
public class ErrorHandler extends JDialog {
public ErrorHandler(<other parameters>, Logger logger) {
/* Display other facts about error, like class name and method name,
which would be passed in <other parameters>, in JTextFields and put
them on the JDialog. */
/* Interrogate the logger to determine the name of the log file to which the application-specific logger is writing. */
String logFileName = logger.getFileName();
String logFilePath = logger.getFilePath();
/* Optional: determine the other FileHandlers in the logger hierarchy and then determine the names of the files to which they are writing. */
???
/* Concatenate the path and file name for each log file and display the concatenated names in a JLabel. This content might look like this:
For more information about this error, consult the following log files:
c:\Corporate\master.log
d:\Application\foo.log
*/
???
}
}
(Incident Review ID: 234250)
======================================================================