Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

logger for multi threaded multi class application

 
glen croteau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a multi threaded multi class application. I wish to write thread safe output to the console.
i have added a logger and set its level for each class.
I can set the formatter for each class also, however I would like to know if I can set the formatter once at a lower level instead of in each class.

This seems a bit much to do in each class. I would like to keep it simple. Even a config file which could be programmatically loaded at start up woudl be good.

Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for "beginning". Moving thread.
 
glen croteau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am now setting the formatter on the default logger and this appears to work.
now i would like to move this to a config file as stated above.

In each class I call a static setup method which handles the config. is there a cleaner solution?
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags. You can edit your post to add them.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
glen croteau wrote:Hello,

I am now setting the formatter on the default logger and this appears to work.
now i would like to move this to a config file as stated above.

In each class I call a static setup method which handles the config. is there a cleaner solution?


If your classes names are really "A" ou "B", you could name it "DEBUG_LEVEL_B_CLASS" and then logger.setLevel(className).

And if its not, you might create a method do encapsulate that if sequence.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic