Configure Logging with Lift

Raising the wiki page during registration means that many settings are performed automatically. My problem now is that I already have a working backend with my own logging configuration and a log4j.propertiesfile in my class path that should be used. There are also dependencies on log4j and SLF4j already on the way to the classes.

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

I am using Lift 2.3-M1 and tried to do the following at the beginning boot():

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

log4j.xml I am currently using fast hacked to just disable 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>

errornous log4j.xml, SAXParser, . DEBUG. :

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

, , , . , LogBoot.logSetup = () => false.

.

+3
2

Lift.

, logback log4j, slf4j-log4j. boot() , default.log4j.xml.

+3

, :

import net.liftweb.common.{ Empty, Logger }
import net.liftweb.http.Bootable
class BootLoader extends Bootable {
  def boot = {
    // other boot configuration ...

    // prevent Lift from messing up my log4j config                                                                                                                          
    Logger.setup = Empty
  }
}
+2

Source: https://habr.com/ru/post/1792802/


All Articles