How to prevent log output from Apache Commons Exec
I am using Apache Commons Exec on a web application in JBoss 4.2.3. Whenever I call Apache Exec it outputs all the console output in th开发者_运维百科e log and this is a lot of output and it could easily fill in my logs in a production environment. How can I prevent this log from printing and only show error logs?
Regards
You can also disable the stdout/stderr/stdin streams from the process by supplying it null streams. This way you don't need to fiddle with the logging levels if you really have no use for the output.
executor.setStreamHandler(new PumpStreamHandler(null, null, null));
In your log4j.properties file for your web app add a line that looks something like this following...
log4j.logger.org.apache.commons.exec=ERROR
You can disable logging on application server level. Just add to jboss-log4j.xml
such line:
<category name="org.apache.commons.exec">
<priority value="ERROR"/>
</category>
精彩评论