[logback-user] insertFromJNDI behavior

Ove Hiltwein ove.hiltwein at immunai.com
Fri Nov 11 08:12:11 CET 2022


Hi,

For our tomcat (10.0.23) web application, we use an env-entry to specify 
the context name in the logback configuration file:
     <insertFromJNDI env-entry-name="java:comp/env/loggingContextName" 
as="loggingContextName" />
     <contextName>${loggingContextName}</contextName>

This context name is also used in defining the log file name:
     <appender name="ERRORFILE" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
         <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDir}/${loggingContextName}_error_%d{yyyy-MM-dd}.log
             </fileNamePattern>
             <maxHistory>7</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>%d{ISO8601} %5p [%X{session}] [%c]: %m%n</pattern>
         </encoder>
         <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
             <level>WARN</level>
         </filter>
     </appender>


And in web.xml we define that environment entry:
     <env-entry>
<env-entry-name>loggingContextName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
         <env-entry-value>server_v4</env-entry-value>
     </env-entry>

This configuration is in accordance with 
https://logback.qos.ch/manual/configuration.html.

Using logback-classic in version 1.2.11, the corresponding log 
information is written to the file server_v4_error_2022-11-09.log, as 
expected.

However, after upgrading to logback-classic version 1.4.4 (or 1.3.4), 
the corresponding log information is written to a file 
loggingContextName_IS_UNDEFINED_error_2022-11-09.log, and tomcat prints 
the following to the console during startup:
14:11:58,019 |-ERROR in 
ch.qos.logback.core.model.processor.DefaultProcessor at 1390cc4c - Can't 
handle model of type class 
ch.qos.logback.core.model.InsertFromJNDIModel  with tag: insertFromJNDI 
at line 5


What am I missing here?


Many thanks
Ove Hiltwein

-- 
Ove Hiltwein @ Nebion AG (an Immunai company) / Zurich (CH)
www.nebion.com


-- 
PLEASE NOTE: The information contained in this message is privileged and 
confidential, and is intended only for the use of the individual to whom it 
is addressed and others who have been specifically authorized to receive 
it. If you are not the intended recipient, you are hereby notified that any 
dissemination, distribution, or copying of this communication is strictly 
prohibited. If you have received this communication in error, or if any 
problems occur with the transmission, please contact the sender.


More information about the logback-user mailing list