Results 1 to 2 of 2
  1. #1
    nbolton is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default Logging to console, should it go to stdout or stderr?

    When logging to the console, is it a better convention to send log INFO messages to stdout or stderr? Taking Eclipse for example, when using the Java Logger class, it seems strange to me that INFO messages are sent to stderr (and so are red in Eclipse); this makes it more difficult to spot errors if you have many INFO messages. While researching how to change this behaviour, I stumbled upon this forum post:

    > Simon wrote:
    > cteb wrote:
    > > Thanks for your help. However, I can't get my Formatter class to run.
    > > My logging properties file is read (I left in an error by mistake and got
    > > error messages on the console). Unfortunately, my formatter is never
    > > used. The regular logging output is sent to the console (stderr instead
    > > of stdout, for some reason; in Eclipse it's red now instead of
    > > black).
    > This is as expected. Why would you
    > expect log messages to go to stdout?
    > stdout should be used for the output
    > or result of your program.

    Source: Need help logging with java.util.logger

    The default setting appears to send to stderr, so perhaps Simon is right. I suppose it is useful if you want to do:

    ./somecmd 1> somecmd.out 2> somecmd.log

    ... but isn't this abusing stderr? Surely only errors/warnings should go to this stream. My application logs all information messages to the logger, which means that my stdout channel is never used, which seems silly.

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    I'd say it's silly. But there is no real convention for when to send things to stdout vs stderr, and it makes sense for the logger utility to use only one or the other, since it has embeeded within the messages what level they are.

Similar Threads

  1. Writing of stdout and stderr to Log4j appender
    By maxrizhkov in forum Advanced Java
    Replies: 0
    Last Post: 01-06-2011, 03:34 PM
  2. Two external app. Redirect stdin to stdout.
    By alenyashka in forum Advanced Java
    Replies: 0
    Last Post: 08-18-2010, 09:26 AM
  3. Replies: 0
    Last Post: 01-22-2010, 01:01 PM
  4. Is there a better way to read from stdout?
    By iceagecoming in forum New To Java
    Replies: 6
    Last Post: 11-06-2009, 10:45 PM
  5. Replies: 1
    Last Post: 10-24-2009, 02:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts