Java Logger Class

J

joshivaibhav

Hello,

I am new to Java and trying to use the Java Logger class.

I am able to log all the messages to my log file, but it also displays
them on the screen.

How to stop the logger from displaying messages on the screen?

Thanks,

Vaibhav
 
K

Knute Johnson

joshivaibhav said:
Hello,

I am new to Java and trying to use the Java Logger class.

I am able to log all the messages to my log file, but it also displays
them on the screen.

How to stop the logger from displaying messages on the screen?

Thanks,

Vaibhav

// remove console logger from root logger
Logger rootLogger = Logger.getLogger("");
Handler[] handlers = rootLogger.getHandlers();
if (handlers[0] instanceof ConsoleHandler)
rootLogger.removeHandler(handlers[0]);
 
R

Real Gagnon

How to stop the logger from displaying messages on the screen?

Modify the logging.properties file located in JRE_HOME\lib (default).

Look for the property handlers and remove the value
java.util.logging.ConsoleHandler

Bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,102
Members
48,773
Latest member
Kaybee

Latest Threads

Top