logback / LOGBACK-1726 [Open]
Variable contextName equals contextName_IS_UNDEFINED

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/LOGBACK-1726

==============================
 Issue created
------------------------------

Dmitriy Vladislavovich Prokin created this issue on 17/Feb/23 4:08 PM
Summary:              Variable contextName equals contextName_IS_UNDEFINED
Issue Type:           Bug
Affects Versions:     1.3.5
Assignee:             Logback dev list
Components:           logback-core
Created:              17/Feb/23 4:08 PM
Environment:
   
  
  Linux, Tomcat 9.0.68
Priority:             Major
Reporter:             Dmitriy Vladislavovich Prokin
Description:
  For our web application (tomcat 9.0.68) using logback-classic, 
logback-core,logback-access  in version 1.2.3, we define the log file name with 
variable "contextName" as described in the documentation, my configuration:
  {code:java}
  <?xml version="1.0" encoding="UTF-8"?>
  
  <configuration scan="true" scanPeriod="30 seconds">
  
      <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
          <discriminator class="com.p.tomcat.PSContextDiscriminator">
              <defaultValue>unknown</defaultValue>
          </discriminator>
          <sift>
              <appender name="FILE-APPENDER" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
                  
<file>${catalina.base}/logs/${contextName}/${contextName}.log</file>
                  <append>true</append>
                  <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                      <!-- daily rollover -->
                      
<fileNamePattern>${catalina.base}/logs/${contextName}/${contextName}-%d{yyyy-MM-dd}-%i.log.zip</fileNamePattern>
                      <!-- keep 30 days' worth of history -->
                      <maxHistory>30</maxHistory>
                      <timeBasedFileNamingAndTriggeringPolicy 
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                          <maxFileSize>100MB</maxFileSize>
                      </timeBasedFileNamingAndTriggeringPolicy>
                  </rollingPolicy>
                  <encoder>
                      <charset>utf-8</charset>
                      <pattern>%d{HH:mm:ss.SSS} [%thread] TX[%X{pstxid}] 
%-5level %logger{5} - %msg%n</pattern>
                  </encoder>
              </appender>
          </sift>
      </appender>
      <root>
          <appender-ref ref="SIFT"/>
      </root>
  
      <appender name="JSONL-LOG" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
          <file>${catalina.base}/logs/tomcat.jsonl</file>
          <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <!-- daily rollover -->
              
<fileNamePattern>${catalina.base}/logs/tomcat-%d{yyyy-MM-dd}-%i.jsonl.zip</fileNamePattern>
              <!-- keep 3 days' worth of history -->
              <maxHistory>3</maxHistory>
              <timeBasedFileNamingAndTriggeringPolicy 
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                  <maxFileSize>100MB</maxFileSize>
              </timeBasedFileNamingAndTriggeringPolicy>
          </rollingPolicy>
          <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
      </appender>
      <root>
          <appender-ref ref="JSONL-LOG"/>
      </root>
      <root level="INFO">
      </root>
  
      <!-- Logger for a correct use of SLF4JBridgeHandler -->
      <!-- PLEASE, DON'T CHANGE ITS LEVEL TO DEBUG AND TRACE -->
      <logger name="org.apache.naming.SelectorContext" level="INFO"/>
      <!-- Logging level listener for JUL 
(http://logback.qos.ch/manual/configuration.html#LevelChangePropagator) -->
      <contextListener 
class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
  
  </configuration>
  {code}
  For version 1.2.3, This works nicely and as expected.
  
  However, after upgrading version 1.3.5, the variable ${contextName} is not 
defined, but in opinion, contextName must have default value "default". 
  
  Now created directory and file with name "unknown", because not found value 
for contextName and use my defaultValue. If I deleted my defaultValue from 
configuration, log file has name "contextName_IS_UNDEFINED"
  
  I tried to set the value of the contextName to use the construction "property"
  {code:java}
  <property name="contextName" value="myContextName" /> {code}
  But the value has not changed.
  
  Why does the variable contextName not exist?


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)

_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-dev

Reply via email to