How to prevent log output from Apache Commons Exec

1.9k views Asked by At

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 the 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

3

There are 3 answers

1
Andrew White On BEST ANSWER

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
0
Lukasz Stelmach On

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>
0
vehnae On

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));