[logback-dev] [JIRA] (LOGBACK-1437) Attempting to log session ID throws if session not set

QOS.CH (JIRA) noreply-jira at qos.ch
Tue Nov 20 02:50:00 CET 2018


Keith Gregory created LOGBACK-1437:
--------------------------------------

             Summary: Attempting to log session ID throws if session not set
                 Key: LOGBACK-1437
                 URL: https://jira.qos.ch/browse/LOGBACK-1437
             Project: logback
          Issue Type: Bug
          Components: logback-access
    Affects Versions: 1.2.3
         Environment: Tomcat 8.5
Oracle JDK 1.8
Logback 1.2.3 (although it appears that the code in 1.3.0-alpha has the same problem)
            Reporter: Keith Gregory
            Assignee: Logback dev list


With a simple web-app that does not automatically create a session, using the following pattern in \{\{logback-access.xml}}:
\{code:xml}
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%h %l %u %user %date "%r" %s %b %sessionID</pattern>
    </encoder>
  </appender>
\{code}

will cause the following exception:

\{code}
20:22:26,782 |-ERROR in ch.qos.logback.core.ConsoleAppender[STDOUT] - Appender [STDOUT] failed to append. java.lang.IllegalStateException: Cannot create a session after the response has been committed
    at java.lang.IllegalStateException: Cannot create a session after the response has been committed
    at     at org.apache.catalina.connector.Request.doGetSession(Request.java:3030)
    at     at org.apache.catalina.connector.Request.getSession(Request.java:2451)
    at     at ch.qos.logback.access.spi.AccessEvent.getSessionID(AccessEvent.java:249)
    at     at ch.qos.logback.access.pattern.SessionIDConverter.convert(SessionIDConverter.java:21)
...
\{code}

I believe that you can resolve this by changing [AccessEvent.getSession()|https://logback.qos.ch/xref/ch/qos/logback/access/spi/AccessEvent.html#L249] to call \{\{getSession(false)}} rather than \{\{getSession()}}.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list