Suppress screen message from Logger

S

Samik R

Hello,

I am using the java Logger api for logging. I want to suppress the default screen messages from using the api. Can anybody help me out?

Following is the code I am using:

// Initiate logging service
Logger MyLogger=Logger.getLogger("");
FileHandler FH=new FileHandler("BundleLog.txt");
FH.setFormatter(new MyLogFormatter());
MyLogger.addHandler(FH);
MyLogger.setLevel(Level.ALL);


Output:
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Connecting to DB: samik
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Running simulation with 3 nodes, Simulation # 0, Repeatation # 1
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: NodeImbalances[0]=0.0
....

I want to get rid of the above lines appearing on screen. The lines with dates etc. do not appear in the file "BundleLog.txt". So the file output is what I want. But I do not want any message on screen.

Thanks for any pointer.
-Samik
 
R

Rhino

Samik R said:
Hello,

I am using the java Logger api for logging. I want to suppress the default
screen messages from using the api. Can anybody help me out?

Following is the code I am using:

// Initiate logging service
Logger MyLogger=Logger.getLogger("");
FileHandler FH=new FileHandler("BundleLog.txt");
FH.setFormatter(new MyLogFormatter());
MyLogger.addHandler(FH);
MyLogger.setLevel(Level.ALL);


Output:
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Connecting to DB: samik
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Running simulation with 3 nodes, Simulation # 0, Repeatation # 1
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: NodeImbalances[0]=0.0
...

I want to get rid of the above lines appearing on screen. The lines with
dates etc. do not appear in the file "BundleLog.txt". So the file output
is what I want. But I do not want any message on screen.

Thanks for any pointer.
-Samik

If you look in the jre/lib directory of your Java SDK, you should find a
file called logging.properties. I believe the default value of the
'handlers' property is 'java.util.logging.ConsoleHandler'. If you set the
default value to blank, that should stop any messages from being sent to the
console. In other words, change this line:

handlers= java.util.logging.ConsoleHandler

to

handlers=

There are lots of comments in the logging.properties file and, if memory
serves, you can also find further information on logging in the
documentation that comes with the SDK. However, if you don't have that
documentation, you can find the information online at
http://java.sun.com/j2se/1.5.0/docs/guide/logging/overview.html.

Rhino
 
K

Knute Johnson

Rhino said:
Hello,

I am using the java Logger api for logging. I want to suppress the default
screen messages from using the api. Can anybody help me out?

Following is the code I am using:

// Initiate logging service
Logger MyLogger=Logger.getLogger("");
FileHandler FH=new FileHandler("BundleLog.txt");
FH.setFormatter(new MyLogFormatter());
MyLogger.addHandler(FH);
MyLogger.setLevel(Level.ALL);


Output:
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Connecting to DB: samik
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Running simulation with 3 nodes, Simulation # 0, Repeatation # 1
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: NodeImbalances[0]=0.0
...

I want to get rid of the above lines appearing on screen. The lines with
dates etc. do not appear in the file "BundleLog.txt". So the file output
is what I want. But I do not want any message on screen.

Thanks for any pointer.
-Samik


If you look in the jre/lib directory of your Java SDK, you should find a
file called logging.properties. I believe the default value of the
'handlers' property is 'java.util.logging.ConsoleHandler'. If you set the
default value to blank, that should stop any messages from being sent to the
console. In other words, change this line:

handlers= java.util.logging.ConsoleHandler

to

handlers=

There are lots of comments in the logging.properties file and, if memory
serves, you can also find further information on logging in the
documentation that comes with the SDK. However, if you don't have that
documentation, you can find the information online at
http://java.sun.com/j2se/1.5.0/docs/guide/logging/overview.html.

Rhino
Or in your program:

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

Samik R

Rhino said:
Hello,

I am using the java Logger api for logging. I want to suppress the
default screen messages from using the api. Can anybody help me out?

Following is the code I am using:

// Initiate logging service
Logger MyLogger=Logger.getLogger("");
FileHandler FH=new FileHandler("BundleLog.txt");
FH.setFormatter(new MyLogFormatter());
MyLogger.addHandler(FH);
MyLogger.setLevel(Level.ALL);


Output:
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Connecting to DB: samik
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Running simulation with 3 nodes, Simulation # 0, Repeatation # 1
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: NodeImbalances[0]=0.0
...

I want to get rid of the above lines appearing on screen. The lines
with dates etc. do not appear in the file "BundleLog.txt". So the
file output is what I want. But I do not want any message on screen.

Thanks for any pointer.
-Samik



If you look in the jre/lib directory of your Java SDK, you should find
a file called logging.properties. I believe the default value of the
'handlers' property is 'java.util.logging.ConsoleHandler'. If you set
the default value to blank, that should stop any messages from being
sent to the console. In other words, change this line:

handlers= java.util.logging.ConsoleHandler

to

handlers=

There are lots of comments in the logging.properties file and, if
memory serves, you can also find further information on logging in the
documentation that comes with the SDK. However, if you don't have that
documentation, you can find the information online at
http://java.sun.com/j2se/1.5.0/docs/guide/logging/overview.html.

Rhino
Or in your program:

// remove console logger from root logger
Logger rootLogger = Logger.getLogger("");
Handler[] handlers = rootLogger.getHandlers();
rootLogger.removeHandler(handlers[0]);
Thanks for the replys. I used the code method.
Regards.
-Samik
 
S

Samik R

Rhino said:
Hello,

I am using the java Logger api for logging. I want to suppress the
default screen messages from using the api. Can anybody help me out?

Following is the code I am using:

// Initiate logging service
Logger MyLogger=Logger.getLogger("");
FileHandler FH=new FileHandler("BundleLog.txt");
FH.setFormatter(new MyLogFormatter());
MyLogger.addHandler(FH);
MyLogger.setLevel(Level.ALL);


Output:
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Connecting to DB: samik
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: Running simulation with 3 nodes, Simulation # 0, Repeatation # 1
Dec 28, 2005 9:53:26 PM java.util.logging.LogManager$RootLogger log
INFO: NodeImbalances[0]=0.0
...

I want to get rid of the above lines appearing on screen. The lines
with dates etc. do not appear in the file "BundleLog.txt". So the
file output is what I want. But I do not want any message on screen.

Thanks for any pointer.
-Samik



If you look in the jre/lib directory of your Java SDK, you should find
a file called logging.properties. I believe the default value of the
'handlers' property is 'java.util.logging.ConsoleHandler'. If you set
the default value to blank, that should stop any messages from being
sent to the console. In other words, change this line:

handlers= java.util.logging.ConsoleHandler

to

handlers=

There are lots of comments in the logging.properties file and, if
memory serves, you can also find further information on logging in the
documentation that comes with the SDK. However, if you don't have that
documentation, you can find the information online at
http://java.sun.com/j2se/1.5.0/docs/guide/logging/overview.html.

Rhino
Or in your program:

// remove console logger from root logger
Logger rootLogger = Logger.getLogger("");
Handler[] handlers = rootLogger.getHandlers();
rootLogger.removeHandler(handlers[0]);
Thanks for the replies. I used the code method.
Regards,
-Samik
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top