Search code examples
javashellloggingapache-commons-logging

Sending System.out to a file and Commons Logging


I am using commons logging:

  private static final Log LOG = LogFactory.getLog(MyClass.class);

Why those logs doesn't go into the log file when I run

sh Main 2>&1 > logfile

I am using the default properties and no log4j.properties are in the classpath.


Solution

  • You have the redirections backwards. They're processed from left to right. Try this:

    sh Main > logfile 2>&1