logback / LOGBACK-1555 [Open] Logback-access %B is not 0 when HTTP status code is 204 No Content
============================== 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-1555 ============================== Issue created ------------------------------ Dongfeng Lu created this issue on 30/Mar/21 7:13 PM Summary: Logback-access %B is not 0 when HTTP status code is 204 No Content Issue Type: Bug Affects Versions: 1.2.3 Assignee: Logback dev list Attachments: rest.zip Components: logback-access Created: 30/Mar/21 7:13 PM Environment: Java 11, Gradle 6.8.3 Priority: Major Reporter: Dongfeng Lu Description: [https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html] says {code:java} %b - Bytes sent, excluding HTTP headers, or '-' if zero %B - Bytes sent, excluding HTTP headers {code} That is, %B returns number 0, instead of '-' if content-length is 0. We expected the same behavior from logback-access. However, this does not seem to be the case. I created a simple Spring Boot project with only "spring-boot-starter-web" and "logback-access:1.2.3", with simple configuration for logback-access.xml. Related to the ticket LOGBACK-1554, I knew %b and %B works only for String object. I created 4 simple REST APIs, all returning String object, but with non-empty string, empty string, null string, and null string with HTTP 204 status code. {code:java} http://localhost:8080/string http://localhost:8080/empty http://localhost:8080/null http://localhost:8080/noContent {code} I configured the app to use both Tomcat Access log and Logback-access log, the corresponding results are Spring Boot Tomcat Access Log {code:java} 0:0:0:0:0:0:0:1 - - [30/Mar/2021:11:27:13 -0500] "GET /string HTTP/1.1" 200 6 6 8 0:0:0:0:0:0:0:1 - - [30/Mar/2021:11:27:15 -0500] "GET /empty HTTP/1.1" 200 - 0 1 0:0:0:0:0:0:0:1 - - [30/Mar/2021:11:27:16 -0500] "GET /null HTTP/1.1" 200 - 0 2 0:0:0:0:0:0:0:1 - - [30/Mar/2021:11:27:19 -0500] "GET /noContent HTTP/1.1" 204 - 0 1 {code} Logback-access Log {code:java} Logback-access 0:0:0:0:0:0:0:1 - - 30/Mar/2021:11:27:13 -0500 "GET /string HTTP/1.1" 200 6 6 8 Logback-access 0:0:0:0:0:0:0:1 - - 30/Mar/2021:11:27:15 -0500 "GET /empty HTTP/1.1" 200 0 0 1 Logback-access 0:0:0:0:0:0:0:1 - - 30/Mar/2021:11:27:16 -0500 "GET /null HTTP/1.1" 200 0 0 2 Logback-access 0:0:0:0:0:0:0:1 - - 30/Mar/2021:11:27:19 -0500 "GET /noContent HTTP/1.1" 204 - - 1 {code} You can see %B in Tomcat access log is 0 when HTTP status is 204. However, it is '-' in logback-access log. I attached my simple project for you to reproduce it. You can unzip it, and run "gradlew clean bootRun". Please let me know if any additional information is needed. Thanks. ============================== This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59) _______________________________________________ logback-dev mailing list logback-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-dev