[logback-user] Problem with Context Selector: No appenders present in context?
Ceki Gulcu
listid at qos.ch
Sat Nov 1 11:32:04 CET 2008
Hello Joop,
I do not have the time to look at this at present time. However, I
suggest that you enter a jira issue and I'll look into asap. There are
other user who have encountered problems with context selectors. So
entering a new issue will raise the priority of context selectors.
Of the top of my head, I suggest that you try using context selectors
without installing jul-to-slf4j nor jcl-over-slf4j to see if that
makes a difference. I suspect not installing jul-to-slf4j might make a
difference. (I am just guessing. Tomcat 5.5 leaks into the web-apps if
the they use commong-logging+log4j. Tomcat 6.x might have different a
leakage. Alternatively, it might just a bug in logback.)
Joop Vriend wrote:
> Hi,
>
> I'm having problems using (or configuring?) the logback Context
> Selector. I followed all the instructions of the manual:
>
> http://logback.qos.ch/manual/contextSelector.html
>
> But I get the error-message:
>
> 20:10:26,365 |-ERROR in Logger[com.ddnh.product.ncmdb] - No appenders
> present in context [ContextApp-NCMDB] for logger [com.ddnh.product.ncmdb].
>
> And when undeploying also:
>
> About to detach context named ContextApp-NCMDB
> No context named ContextApp-NCMDB was found.
>
> I'm using Tomcat 6.0 (with -Dlogback.ContextSelector=JNDI).
> I placed all the slf4j and logback jars in the TOMCAT_HOME/lib directory:
>
> slf4j-api-1.5.5.jar
> logback-core-0.9.11.jar
> logback-classic-0.9.11.jar
> logback-access-0.9.11.jar
> jul-to-slf4j-1.5.5.jar
> jcl-over-slf4j-1.5.5.jar
> janino.jar
>
> I edited my web.xml of my webapp "NCMDB":
>
> <env-entry>
> <description>JNDI logging context for this app</description>
> <env-entry-name>logback/context-name</env-entry-name>
> <env-entry-type>java.lang.String</env-entry-type>
> <env-entry-value>ContextApp-NCMDB</env-entry-value>
> </env-entry>
>
> <env-entry>
> <description>URL for configuring logback context</description>
> <env-entry-name>logback/configuration-resource</env-entry-name>
> <env-entry-type>java.lang.String</env-entry-type>
> <env-entry-value>logback.xml</env-entry-value>
> </env-entry>
>
> <listener>
>
> <listener-class>ch.qos.logback.classic.selector.servlet.ContextDetachingSCL</listener-class>
> </listener>
>
> <filter>
> <filter-name>LoggerContextFilter</filter-name>
>
> <filter-class>ch.qos.logback.classic.selector.servlet.LoggerContextFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>LoggerContextFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
>
> And the logback.xml (in WEB-INF/classes) is as follows:
>
> <configuration>
>
> <evaluator name="WARN_EVALUATOR">
> <expression>level == WARN</expression>
> </evaluator>
>
> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%date{yyyy-MM-dd HH:mm:ss} %class %method
> \(%file:%line\)%n %level:
> %message%n%caller{5,WARN_EVALUATOR}%exception{15}</pattern>
> </layout>
> </appender>
>
> <appender name="RootFileAppender"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <append>true</append>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>
> <fileNamePattern>${catalina.base}/logs/ncmdb.ddnh.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
> </rollingPolicy>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%date{yyyy-MM-dd HH:mm:ss} %class %method
> \(%file:%line\)%n %level:
> %message%n%caller{5,WARN_EVALUATOR}%exception{15}</pattern>
> </layout>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>DEBUG</level>
> </filter>
> </appender>
>
> <logger name="com.ddnh.product.ncmdb" additivity="false">
> <level value="DEBUG"/>
> <appender-ref ref="RootFileAppender"/>
> <appender-ref ref="RootEmailAppender"/>
> </logger>
>
> <root>
> <level value="DEBUG"/>
> <appender-ref ref="STDOUT" />
> <appender-ref ref="RootFileAppender"/>
> <appender-ref ref="RootEmailAppender"/>
> </root>
>
> </configuration>
>
>
> What am I doing wrong?? Any help is appreciated.
>
> Thanks, Joop.
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the Logback-user
mailing list