-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
6
-
Cause Known
-
x86
-
linux
A DESCRIPTION OF THE REQUEST :
It would be extremely helpful to have a pattern that would allow inserting the user.name system property into the filename of a log file. A possible pattern is %n.
It'd be very easy to add this in. On line 498 of java.util.logging.FileHandler.generate(), simply add this else if block:
} else if (ch2 == 'n') {
word += System.getProperty("user.name");
ix++;
continue;
}
JUSTIFICATION :
Practicality and convenience. Allows multiple user of the application running on the same linux box to have their own identifiable logs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If I configure FileHandler.pattern = %t/myapp-%n/main.log, then I'd like to have the FileHandler to expand this to /tmp/myapp-<user.name>/main.log.
ACTUAL -
Behavior does not currently exist.
CUSTOMER SUBMITTED WORKAROUND :
It's tedious, but can be worked around.
Create a package in your application; ex. myapp.utils.logging. Copy the source of java.util.logging.Filehandler into myapp.utils.logging.MyFileHandler (or whatever you want to name it). Change the name of the class accordingly, but still extend the StreamHandler class. Import all necessary java.util.logging packages.
Next, you have to copy all of the "get*Property()" methods from java.util.logging.LogManager into MyFileHandler and change the code to call these methods instead of those in LogManager. Within these methods, get an instance of the LogManager and then they should work.
Finally, in all of the constructors, comment out the calls to java.util.logging.Handler.checkAccess(), or, alternatively, do something similar to what you did with the LogManager methods.
It would be extremely helpful to have a pattern that would allow inserting the user.name system property into the filename of a log file. A possible pattern is %n.
It'd be very easy to add this in. On line 498 of java.util.logging.FileHandler.generate(), simply add this else if block:
} else if (ch2 == 'n') {
word += System.getProperty("user.name");
ix++;
continue;
}
JUSTIFICATION :
Practicality and convenience. Allows multiple user of the application running on the same linux box to have their own identifiable logs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If I configure FileHandler.pattern = %t/myapp-%n/main.log, then I'd like to have the FileHandler to expand this to /tmp/myapp-<user.name>/main.log.
ACTUAL -
Behavior does not currently exist.
CUSTOMER SUBMITTED WORKAROUND :
It's tedious, but can be worked around.
Create a package in your application; ex. myapp.utils.logging. Copy the source of java.util.logging.Filehandler into myapp.utils.logging.MyFileHandler (or whatever you want to name it). Change the name of the class accordingly, but still extend the StreamHandler class. Import all necessary java.util.logging packages.
Next, you have to copy all of the "get*Property()" methods from java.util.logging.LogManager into MyFileHandler and change the code to call these methods instead of those in LogManager. Within these methods, get an instance of the LogManager and then they should work.
Finally, in all of the constructors, comment out the calls to java.util.logging.Handler.checkAccess(), or, alternatively, do something similar to what you did with the LogManager methods.