We use Log4j (and Commons Logging) to log our error messages. Now we want to set up an additional log appender that outputs fatal errors to syslog, but without the exceptionally long Java stacktraces (those will still be available in the full log file).
How would one configure this (using log4j.xml)? Is there a filter available to ignore the stack traces?
The "nopex" or "nopexception" conversion word in logback-classic (log4j's successor) disables printing stack traces. The "nopex" conversion word is documented along with the rest of conversion words. You need to scroll down a little.
If you need further information on this topic, please contact the logback-user mailing list.
If you use log4j > 1.2.16, you can use the EnhancedPatternLayout layout.
Example (with a log4j.properties file), define it as the layout of your appender, and then add
%throwable{0}
in the conversion pattern: