In running some JUnit tests I start with the following to set up Log4J:
BasicConfigurator.configure()
I’m then calling the following via Commons Logging:
LogFactory.getLogger(this.getClass()).fatal(exception)
This doesn’t print stack traces though (only the exception message).
I need to know what steps are necessary to print stack traces via the simplified logging setup used in JUnit tests? I would prefer not to have to fully configure Log4J just for JUnit tests, but if I must, let me know.
This is nothing to do with the logger configurations.
Read the javadoc for the
fatal(Object)method. It says:If you want the logs to include a stacktrace, you must use the 2 argument version of the method. This applies to the corresponding methods for other log levels as well.