简体   繁体   English

将System.out发送到文件和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. 我正在使用默认属性,并且classpath中没有log4j.properties。

You have the redirections backwards. 您有向后重定向。 They're processed from left to right. 它们是从左到右处理的。 Try this: 尝试这个:

sh Main > logfile 2>&1 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM