You pass the exception directly to the logger, e.g.
try {
...
} catch (Exception e) {
log.error( "failed!", e );
}
It’s up to log4j to render the stack trace.
More Related Contents:
- Log4j formatting: Is it possible to truncate stacktraces?
- How to Create a Custom Appender in log4j2?
- Setting a log file name to include current date in Log4j
- Configuring Log4j Loggers Programmatically
- How can I create 2 separate log files with one log4j config file?
- log4j: Log output of a specific class to a specific appender
- In log4j, does checking isDebugEnabled before logging improve performance?
- Dynamically Changing log4j log level
- log4j configuration via JVM argument(s)?
- Is it worth to use slf4j with log4j2
- How to send java.util.logging to log4j?
- Log4j: How to configure simplest possible file logging?
- how to make log4j to write to the console as well
- Disabling Log4J Output in Java
- Java Logging vs Log4J [closed]
- NullPointerException stack trace not available without debug agent
- How to delete old logs with log4j2
- Print full call stack on printStackTrace()?
- Redirect System.out and System.err to slf4j
- Are there technical reasons to prefer using logback instead of log4j?
- Where do I configure log4j in a JUnit test class?
- How to specify Log4J 2.x config location?
- LOG4J: Modify logged message using custom appender
- Configuring RollingFileAppender in log4j
- Log runtime Exceptions in Java using log4j
- Enable Hibernate logging
- Log4J2 property substitution – default
- How to create different log files for different packages using same log4j logger?
- Log4j2 (2.1) custom plugin not detected by packages attribute
- Log4J: Strategies for creating Logger instances