Skip to content

Make Tomcat Log Stuff to Console (in Eclipse)

December 7th, 2016 - SoftwareTutorial(1 min)

TL;DR: in your project’s src/main/resources add the CONSOLE setting to the log4j.properties file.

While trying to add features to a web application, I stumbled on an odd situation: my Eclipse Console would show only log messages for tomcat processes, none of my logs. I’ve tried to add a logger properties in Tomcat itself in ${CATALINA_BASE}/lib, but I had no luck.

The solution is to use your app’s own log4j.properties (in src/main/resources) and enable CONSOLE logger. My file looks like this now:

# Logger file

log4j.rootLogger=INFO, CONSOLE

# Console logger
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %5p %c{1}:%L - %x - %m%n

# 3rd party components
#
log4j.logger.org.hibernate=INFO
log4j.logger.org.apache=INFO
log4j.logger.org.springframework=INFO
log4j.logger.org.displaytag=INFO

# My application
#
log4j.logger.my.app=DEBUG

where my.app is my application’s package name (e.g. com.laurivan.helloworld).

HTH,

Share on
Reddit
Linked in
Whatsapp

A little experiment: