• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Logger question

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!