Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure logging with Lift

The Lift wiki page on logging states that a lot of setup is done automatically. Right now my problem is that I already have a running backend with its own logging configuration and a log4j.properties file in my classpath which should be used. There are also dependencies to log4j and SLF4j already in the classpath.

The main problem is that I get complete debug output for everything. Hibernate in particular -- which is very annoying.

I am using Lift 2.3-M1 and tried doing the following in the beginning of boot():

Logger.setup = Full(Log4j.withFile(getClass().getResource("/props/log4j.xml")))

The log4j.xml I am currently using is quickly hacked together to simply suppress DEBUG output.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration threshold="info" xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="CA" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="[%p] %c{2} %m%n"/>
    </layout>
  </appender>
  <root>
    <level value="info"/>
    <appender-ref ref="CA"/>
  </root>
</log4j:configuration>

When I create an errornous log4j.xml I also get an error from the SAXParser so it must be parsed. However I am still getting all DEBUG output. A second try was doing the following:

LiftRules.configureLogging = () => ()
Logger.setup = Full(Logback.withFile(getClass().getResource("/props/log4j.xml")))

Since I do not want to have Lift configure logging for me since the backend is already configured I would like to turn it completely off now. Oh and I also tried LogBoot.logSetup = () => false with no luck.

I would greatly appreciate any help on this issue.

like image 635
Joa Ebert Avatar asked Sep 10 '25 18:09

Joa Ebert


1 Answers

The question got answered on the Lift mailing list.

The fix is to remove the logback dependency and to include both log4j and slf4j-log4j. No other configuration in boot() is required besides a valid default.log4j.xml.

like image 111
Joa Ebert Avatar answered Sep 13 '25 15:09

Joa Ebert