A basic setup for Log4j when using Freemarker

So I’m using Log4j in a project I’m working on, and I kept getting warnings from log4j when starting to use Freemarker…

log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

In order to resolve these issues, I had to import the following classes:

import freemarker.log.Logger;
import org.apache.log4j.BasicConfigurator;

…And run the following commands:

Logger.selectLoggerLibrary(Logger.LIBRARY_LOG4J);
BasicConfigurator.configure();

Happy logging and templating!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s