Suppress screen message from Logger

Discussion in 'Java' started by Samik R, Dec 29, 2005.

  1. Samik R

    Samik R Guest

    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
    Samik R, Dec 29, 2005
    #1
    1. Advertising

  2. Samik R

    Rhino Guest

    "Samik R" <> wrote in message
    news:dovnq0$gtm$...
    > 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
    Rhino, Dec 29, 2005
    #2
    1. Advertising

  3. Rhino wrote:
    > "Samik R" <> wrote in message
    > news:dovnq0$gtm$...
    >
    >>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]);

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Dec 29, 2005
    #3
  4. Samik R

    Samik R Guest

    On 12/29/2005 1:00 AM, Knute Johnson wrote:
    > Rhino wrote:
    >
    >> "Samik R" <> wrote in message
    >> news:dovnq0$gtm$...
    >>
    >>> 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
    Samik R, Dec 29, 2005
    #4
  5. Samik R

    Samik R Guest

    On 12/29/2005 1:00 AM, Knute Johnson wrote:
    > Rhino wrote:
    >
    >> "Samik R" <> wrote in message
    >> news:dovnq0$gtm$...
    >>
    >>> 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
    Samik R, Dec 30, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sachin
    Replies:
    1
    Views:
    951
    Soren Kuula
    Feb 3, 2006
  2. KC Wong

    Suppress DOS screen

    KC Wong, Mar 31, 2005, in forum: C++
    Replies:
    1
    Views:
    813
    Victor Bazarov
    Mar 31, 2005
  3. Christian Seberino
    Replies:
    0
    Views:
    341
    Christian Seberino
    Oct 21, 2003
  4. cap
    Replies:
    3
    Views:
    272
    James Edward Gray II
    Dec 11, 2005
  5. Georges Ko
    Replies:
    4
    Views:
    259
    Georges Ko
    Jul 26, 2006
Loading...

Share This Page