Investigate if JSON format can be used to provider structured logs in FOLIO, both for Okapi and backend modules (with RMB providing default logging configuration).
If successful JSON format will be used to provide structured data in the logs. The following fields are candidates for inclusion:
- stacktrace - plain text joined by \n symbol (for errors)
- moduleId (e.g mod-authtoken-1.2.3)
- uri (e.g /inventory-storage/instances) e.g an HTTP API path
- queryString as a separate element to capture HTTP parameters
- code (e.g 200, 400, 500) e.g an HTTP response code
- duration (e.g 1234, in msecs) time it took to complete an operation
- sql SQL Query
A complete set is still being discussed, see https://wiki.folio.org/pages/viewpage.action?pageId=36579228
FOLIO DevOps team has been experimenting with JSON logging configuration and have seen the following issues trying to enable JSON logging:
- poor performance when using the "location" information (like class)
- disappearance of existing structured fields when adding custom fields
See details of this investigation below.
We will put utilities (e.g FolioLoggingContext) and default log4j config in a shared project (okapi-common since it's used by RMB and will make the classes available in all RMB projects).
We will let module developers know to remove their existing log4j configuration to make use of the default one. They will be also able to use the default one as a starting point and put in additional customize.