A basic setup for Log4j when using Freemarker

26 Dec 2014 . posts . Comments
#Freemarker #log4j #Programming

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!! —

Comments:

#### Bill -

Hi- Thanks for posting this, I am getting the same error and hope that your solution will solve my issue as well. When you say, “and run the following commands…”, where exactly did you run those commands, or put those lines in your code? Thanks in advance, -Bill



Me

Anthony is an Australian software engineer and mathematician. As a UTS MBT graduate, Anthony is the technology co-founder of a property and cycling-tech startup and enjoys teaching and learning coding with the Australian startup scene.