SAP / cf-java-logging-support

The Java Logging Support for Cloud Foundry supports the creation of structured log messages and the collection of request metrics
Apache License 2.0
76 stars 46 forks source link

Missing fields missing in Request log #177

Open i060582 opened 5 months ago

i060582 commented 5 months ago

Hi,

We want to add field tenant_id in Request logs.

image.

We don't understand why each request (identified by a correlation_id) has 2 entries in kibana

  1. first entry with a logger equals to empty '-'
  2. second entry with a logger equals to 'com.sap.hcp.cf.logging.servlet.filter.RequestLogger' but the following fields method, response_status (etc) are not informed.

Is it possible to get a complete entry with all fields correctly informed with a tenant_id (guid)?

Thank you for your support.

KarstenSchnitter commented 5 months ago

Hi,

Thanks for reaching out with this issue. This is only somewhat loosely related to this library. I guess that the screenshot you are showing is taken from SAP BTP Application Logging service for SAP BTP or SAP Cloud Logging service. Both services receive the log stream generated by the CF runtime. This includes the logs your application emitted as well as the runtime logs. Using cf-java-logging-support will generate request logs with logger com.sap.hcp.cf.logging.servlet.filter.RequestLogger. These are half of the logs you see. The other request logs are generated by the CF Gorouter. They are recognisable by the field "source_type": "[RTR]". Those are the other half of request logs. You may notice, that they have slightly different timings, since the Router logs include networking rountrip from Gorouter to the application. The library logs only cover the request handling latency. Another major difference is, that you can add fields to the library router logs as documented but the Gorouter log format and contents is fixed by the CF runtime.

I am not sure, why the library request logs do not contain method, request and response_status. This should all be managed by the RequestLoggingFilter as documented here. Please check you are using the right module: cf-java-logging-support-servlet for javax.servlet or cf-java-logging-support-servlet-jakarta for jakarta.servlet. If you have other information on how to reproduce the incomplete request logs, please let me know.

Best Regards, Karsten