Christopher Mason <[email protected]> writes:

> Is log4j a hard dependency to break?  It seems like you're using slf4j
> most places, but then have some hard deps for configuration.  I'm
> using logback.  How hard would it be for me to remove the log4j dep
> and replace with slf4j/logback.  (I have logback already configured in
> my servlet container.)

Fwiw, here's how I setup slf4j/logback. It enables per-runmode logback.xml files
just as with log4j

 private def setupLogging() {
    import org.slf4j.LoggerFactory
    import ch.qos.logback.classic.LoggerContext;
    import ch.qos.logback.core.util.StatusPrinter;
    import ch.qos.logback.classic.joran.JoranConfigurator;

    def findTheFile: Box[(_root_.java.net.URL, String)] = 
(first(Props.toTry.flatMap(f => {List(f()+"logback.xml")}))
    (name =>tryo(getClass.getResource(name)).filter(_ ne null).map(s => (s, 
name))))

    
    findTheFile match {
      case Full((url, name)) => {
          val lc = 
LoggerFactory.getILoggerFactory().asInstanceOf[LoggerContext];
          val configurator = new JoranConfigurator();
          configurator.setContext(lc);
          // the context was probably already configured by default 
configuration 
          // rules
          lc.reset(); 
          configurator.doConfigure(url);
          StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
      }
      case _ => 
    }
    Slf4jLogBoot.enable()
  }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to