wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Preventing Logging to Console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Preventing Logging to Console" Watch "Preventing Logging to Console" New topic
Author

Preventing Logging to Console

Alan Morgan
Ranch Hand

Joined: Apr 18, 2005
Posts: 113
Hey all,

I use the java Logging framework to log events that occur during the running of the application.

I use a FileHandler and send the messages out to multiple files.

However the log messages also appear on the console as I run.
How do I turn this off ?

Thanks,
Alan.
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
I run it through Eclipse and also observe this.
I havent looked deep into this, but I guess redirecting the output (system out) to something like /dev/null would work.
Abiodun Okusolubo
Ranch Hand

Joined: Apr 25, 2004
Posts: 72
Try using Logger.getLogger("mylog").setUseParentHandlers(false);


SCJP, SCWCD, SCJD : in the making.
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
This works great !!!
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
are you talking about logging during development or logging in your final submission?

if it is for the latter, take this into account:

i was not allowed to submit a configuration file for logging. so i favoured standard logging over hard-coded configuration, which means output of info-level and console.

passed with it, btw :-)

jan
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
The question at hand was that once you initiated the application and have the logging enabled, it writes to the log file as well as displays on the console. Thats not the required behavior
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
yes, i got that. ;-)

but my point was: if you use anything else but standard-logging - how are you configuring it? as config files and vm-arguments are not an option, you would have to write something hardcoded, or not? how are you configuring the fileapender? how does it know where to write to, in which file?

being faced with this question, i decided to favor standard-logging over any hardcoded configuration...

many greetings,
jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preventing Logging to Console
 
Similar Threads
Client configuration, please help
Sun's Logger to log message in App Server log (SystemOut.log in WAS)
Log4j logging to NT Event log
Integration of Commons Logging framework with Weblogic
Log4j ...selective logging to appenders