[logback-user] Problem with Context Selector: No appenders present in context?

Joop Vriend joop.vriend at ddnh.nl
Fri Oct 31 20:46:01 CET 2008


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.


More information about the Logback-user mailing list