ClassCastException: org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext

2,060 views
Skip to first unread message

Albert Sikkema

unread,
Jan 2, 2012, 12:11:17 PM1/2/12
to lif...@googlegroups.com
Hi all,

I'm trying to setup lift's logging properly using logback as described in the wiki. We're using lift-webkit so the default LoggingAutoConfigurer should simply work when I put the logback-classic dependency in the pom.xml right?. However, when I run the app (in jetty) I get the following stacktrace:

2012-01-02 17:27:41.058:WARN::failed LiftFilter: java.lang.ClassCastException: org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
2012-01-02 17:27:41.058:WARN::Failed startup of context org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@4921a90{/,/webapp}
java.lang.ClassCastException: org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
at net.liftweb.common.Logback$.withFile(Logging.scala:324)
at net.liftweb.util.LoggingAutoConfigurer$$anonfun$apply$1$$anonfun$apply$mcV$sp$2$$anonfun$apply$6.apply(Log.scala:73)
at net.liftweb.util.LoggingAutoConfigurer$$anonfun$apply$1$$anonfun$apply$mcV$sp$2$$anonfun$apply$6.apply(Log.scala:73)
at net.liftweb.common.Full.map(Box.scala:491)
at net.liftweb.util.LoggingAutoConfigurer$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Log.scala:73)
at net.liftweb.util.LoggingAutoConfigurer$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Log.scala:72)
at net.liftweb.common.Full.map(Box.scala:491)
at net.liftweb.util.LoggingAutoConfigurer$$anonfun$apply$1.apply$mcV$sp(Log.scala:72)
at net.liftweb.common.Logger$$anonfun$checkConfig$1.apply(Logging.scala:24)
at net.liftweb.common.Logger$$anonfun$checkConfig$1.apply(Logging.scala:24)
at net.liftweb.common.Full.foreach(Box.scala:489)
at net.liftweb.common.Logger$.checkConfig(Logging.scala:24)
at net.liftweb.common.Logger$.apply(Logging.scala:52)
at net.liftweb.common.Loggable$class.$init$(Logging.scala:254)
at net.liftweb.http.LiftServlet.<init>(LiftServlet.scala:31)
at net.liftweb.http.LiftServlet.<init>(LiftServlet.scala:35)
at net.liftweb.http.provider.HTTPProvider$class.bootLift(HTTPProvider.scala:95)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:757)
at net.liftweb.http.provider.servlet.ServletFilterProvider$class.init(ServletFilterProvider.scala:40)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:757)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
.....
I've tried to follow the stack trace myself, it tries to execute the Logback.withFile which seems correct to me. It executes: 
val lc = LoggerFactory.getILoggerFactory().asInstanceOf[LoggerContext];
which apparently returns a SubstituteLoggerFactory which is the case for an ongoing initialization and causes the CCE.

Now I don't know that much about the details of slf4j nor logback, I guess my config is ok, but I can't seem to find what's causing this issue. I'll try to setup a test lift-project to reproduce this, but I'd also love to fix this by simply following the trail but I'm a bit stuck here. Any suggestions? 

Kind regards,

Albert Sikkema
P.S. I'm using:  
net.liftweb:lift-webkit_2.9.0-1:jar:2.4-M5:compile
ch.qos.logback:logback-classic:jar:0.9.28:compile



Diego Medina

unread,
Jan 2, 2012, 12:27:16 PM1/2/12
to lif...@googlegroups.com

I have a project that uses logback on github.
It uses sbt, but it may help you
https://github.com/fmpwizard/lift_auction/blob/master/project/build/LiftProject.scala

https://github.com/fmpwizard/lift_auction/blob/master/src/main/resources/props/default.logback.xml

And I just log things by exceeding Logger and then using

info ("test here")

Hope it helps

Diego
Sent from my android cell

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

Albert Sikkema

unread,
Jan 4, 2012, 4:01:55 AM1/4/12
to lif...@googlegroups.com
Hi Diego,

Thanks for your reply. I've tested your solution and it works. I've tried to narrow down my issue by removing dependencies. Somehow I got it working after moving to scala 2.9.1. Not entirely sure what the cause was, but it works now!

Thanks again,

Albert
Reply all
Reply to author
Forward
0 new messages