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
Rhino - 29 Dec 2005 04:51 GMT
> Hello,
>
[quoted text clipped - 25 lines]
> 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
Knute Johnson - 29 Dec 2005 07:00 GMT
>>Hello,
>>
[quoted text clipped - 45 lines]
>
> Rhino
Or in your program:
// remove console logger from root logger
Logger rootLogger = Logger.getLogger("");
Handler[] handlers = rootLogger.getHandlers();
rootLogger.removeHandler(handlers[0]);

Signature
Knute Johnson
email s/nospam/knute/
Samik R - 29 Dec 2005 23:45 GMT
>>> Hello,
>>>
[quoted text clipped - 52 lines]
> Handler[] handlers = rootLogger.getHandlers();
> rootLogger.removeHandler(handlers[0]);
Thanks for the replys. I used the code method.
Regards.
-Samik
Samik R - 30 Dec 2005 02:19 GMT
>>> Hello,
>>>
[quoted text clipped - 52 lines]
> Handler[] handlers = rootLogger.getHandlers();
> rootLogger.removeHandler(handlers[0]);
Thanks for the replies. I used the code method.
Regards,
-Samik