[logback-dev] [JIRA] Updates for LOGBACK-1554: Logback-access %b is empty, most of time

QOS.CH (JIRA) noreply-jira at qos.ch
Fri Mar 26 18:23:00 CET 2021


logback / LOGBACK-1554 [Open]
Logback-access %b is empty, most of time

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

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-1554

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

Dongfeng Lu created this issue on 26/Mar/21 6:08 PM
Summary:              Logback-access %b is empty, most of time
Issue Type:           Bug
Affects Versions:     1.2.3
Assignee:             Logback dev list
Attachments:          rest.zip
Components:           logback-access
Created:              26/Mar/21 6:08 PM
Environment:          Java 11, Gradle
Priority:             Major
Reporter:             Dongfeng Lu
Description:
  Originally, we were trying to get Tomcat access log in JSON format. We followed the example in https://github.com/jochenchrist/spring-boot-access-logs-demo and everything seems to work well, except that we were not able to get response's content length.
  
  To narrow things down, I created a simple Spring Boot project with only "spring-boot-starter-web" and "logback-access:1.2.3" (No logstash here), with simple configuration for logback-access.xml. I created 4 simple REST APIs, started the app and ran the following 4 requests in browser.
  {code}
  http://localhost:8080/list
  http://localhost:8080/map
  http://localhost:8080/long
  http://localhost:8080/string 
  {code}
  The browser displays the response correctly in JSON format. And in the console, the corresponding access log entries were
  {code}
  0:0:0:0:0:0:0:1 - - 26/Mar/2021:11:04:34 -0500 "GET /list HTTP/1.1" 200 124 - - -
  0:0:0:0:0:0:0:1 - - 26/Mar/2021:11:04:36 -0500 "GET /map HTTP/1.1" 200 13 - - -
  0:0:0:0:0:0:0:1 - - 26/Mar/2021:11:04:37 -0500 "GET /long HTTP/1.1" 200 6 - - -
  0:0:0:0:0:0:0:1 - - 26/Mar/2021:11:04:39 -0500 "GET /string HTTP/1.1" 200 6 6 6 6
  {code}
  Following http://logback.qos.ch/manual/layouts.html, I tried all the conversion word for the content length, "%b", "%B", and "%bytesSent", and they all seem to work and generate the content length, but ONLY if the response return type is "String". They did NOT generate the content length for Map, List or even a Long object.
  
  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)



More information about the logback-dev mailing list