Logging exception with java.util.logging.Logger#log() to file only

Discussion in 'Java' started by Royan, Apr 1, 2008.

  1. Royan

    Royan Guest

    I'm logging exceptions with java.util.logging.Logger#log() (i can't
    use anything apart from standard Java API) and i don't want any stack
    trace to appear in stdout or stderr is there any way I can filter or
    redirect all output that is produced buy this method into the file
    only?
     
    Royan, Apr 1, 2008
    #1
    1. Advertisements

  2. Re: Logging exception with java.util.logging.Logger#log() to fileonly

    Royan wrote:
    > I'm logging exceptions with java.util.logging.Logger#log() (i can't
    > use anything apart from standard Java API) and i don't want any stack
    > trace to appear in stdout or stderr is there any way I can filter or
    > redirect all output that is produced buy this method into the file
    > only?


    You can use Level.FINE to log exception and Level.INFO for others message.

    Then you can configure the ConsoleHandler to output only the the message
    above the INFO level and the FileHandler to output ALL messages.
    These configurations are done in the logging.properties configuration file.
    There is a global logging.properties file located in your {JRE}/lib
    directory, but you can use your own with:

    java -Djava.util.logging.config.file=mylogging.properties

    --
    Andrea Francia
    http://www.andreafrancia.it/
     
    Andrea Francia, Apr 1, 2008
    #2
    1. Advertisements

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. Stefan Siegl
    Replies:
    0
    Views:
    1,172
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    10,396
    janne
    Sep 10, 2004
  3. CD1
    Replies:
    3
    Views:
    18,906
  4. Gugle
    Replies:
    3
    Views:
    1,798
    Gugle
    Dec 12, 2006
  5. Frank
    Replies:
    1
    Views:
    1,099
    Daniel Pitts
    Dec 7, 2006
  6. cteb
    Replies:
    5
    Views:
    7,977
    Arne Vajhøj
    Oct 5, 2008
  7. johnmmcparland
    Replies:
    1
    Views:
    5,126
    johnmmcparland
    Jan 9, 2009
  8. Santha
    Replies:
    0
    Views:
    1,213
    Santha
    Jan 14, 2010
Loading...