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.
posted 13 years ago
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.
Let's go to the waterfront with this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads