aspose file tools*
The moose likes I/O and Streams and the fly likes Logger question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Logger question" Watch "Logger question" New topic
Author

Logger question

Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Hi all,
I have a program with multiple processes. Each process spawn multiple threads. If I want each process to have a unique log file name (all threads associated with a process should write to the same log file), how would I go about doing this to gaurantee uniqueness?
I am mostly looking for setting the name of the log file dynamically in my program rather than using logging.properties file. Since I want each process to be able to specify its name as part of the logger name. For example if there are 3 processes in the system named two Servers and Client, log names should be something like:
Client0.log
Server0.log
Server1.log
Thank you,
Payam.
Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Here is how I am doing it using logging.properties file:
# default file output is in user's home directory.
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.formatter =
java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append = true
java.util.logging.FileHandler.level = FINE

Now, the log file names are all unique, but are names java0.log, java1.log, java2.log. If there is a way to somehow change the above pattern to include the name of the class that starts the process, it would be great.
Thanks,
Payam.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Logger question