Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Logging Question

 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gang,

I am pretty new to JDK-logging and I have a simple question for you all.

Below is a piece of code that appears on my application



Basically, I want to use Logging API in my application & log everything to my log file wherease log fatal errors / exceptions to the console and file.

But for some wierdo reason


logs both to my log file as well as console

What am I doing wrong?
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a default ConsoleHandler with level INFO, defined in jre/lib/logging.properties.

Could that be the reason for this behaviour?
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any one?
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sonny is right, there's a default configuration in which a ConsoleHandler is defined, with INFO Level enabled for root logger.

Try to add

at the beggining of yout code.

Or, better, define your logging configuration in a logging properties file which will override the default one.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Seb. That worked like a charm!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic