Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Suppress screen message from Logger

Thread view: 
Samik R - 29 Dec 2005 04:13 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.