Skip to content

JSON logging - #5023

Merged
leonardehrenfried merged 4 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:json-logging
Apr 12, 2023
Merged

JSON logging#5023
leonardehrenfried merged 4 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:json-logging

Conversation

@leonardehrenfried

@leonardehrenfried leonardehrenfried commented Apr 3, 2023

Copy link
Copy Markdown
Member

Summary

This allows users of OTP to switch to JSON-formatted logs by setting an command line parameter like this:

java -Dotp.logging.format=json -jar otp.jar --load --serve data

A (pretty-printed) example of a log message looks like this:

{
  "@timestamp": "2023-04-03T13:28:08.058026697+02:00",
  "level": "INFO",
  "logger_name": "org.opentripplanner.routing.graph.SerializedGraphObject",
  "thread_name": "main",
  "message": "Reading graph from 'tampere/graph.obj'"
}

I've also included Entur's configuration in this PR. We can discuss if this is necessary as you may have more customization needs that you don't want to upstream.

Issue

Closes #5015

Documentation

Added.

cc @derhuerst @hbruch

@leonardehrenfried leonardehrenfried added the !Improvement A functional improvement or micro feature label Apr 3, 2023
@leonardehrenfried
leonardehrenfried requested a review from a team as a code owner April 3, 2023 11:27
@codecov

codecov Bot commented Apr 3, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage has no change and project coverage change: +0.15 🎉

Comparison is base (53cecaa) 64.16% compared to head (c3b7d99) 64.32%.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5023      +/-   ##
=============================================
+ Coverage      64.16%   64.32%   +0.15%     
- Complexity     13723    13803      +80     
=============================================
  Files           1687     1689       +2     
  Lines          66741    66771      +30     
  Branches        7188     7189       +1     
=============================================
+ Hits           42826    42949     +123     
+ Misses         21516    21417      -99     
- Partials        2399     2405       +6     

see 63 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@derhuerst

derhuerst commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

"@timestamp": "2023-04-03T13:28:08.058026697+02:00"

Note that according to Wikipedia ISO 8601 specifies no maximum number of fractional digits, some widely used implementations limit the number of fractions:

I'm not sure if these limitations are worth reducing the precision of OTP's logs. On the other hand, the 9th fractional digit has limited value anyways.

@leonardehrenfried

Copy link
Copy Markdown
Member Author

You're right in that nobody needs that ridiculous level of precision however, there is value in just using the default configuration (which this is) and not fiddle it.

@vpaturet

vpaturet commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

It is probably not necessary to add the Entur configuration, we use already different versions of it, so we need to customize it anyway.
It might be a good example configuration that could be added in Logging.md, though.

@vpaturet vpaturet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully with the Entur configuration by overriding the embedded logback configuration file with an external configuration file.

Comment thread docs/Logging.md
vpaturet
vpaturet previously approved these changes Apr 4, 2023
Comment thread docs/Logging.md Outdated
Co-authored-by: Johan Torin <jtorin@users.noreply.github.com>
@t2gran

t2gran commented Apr 11, 2023

Copy link
Copy Markdown
Member

Looks good to me, but I will leave the formal reviews to the assigned reviewers.

@t2gran t2gran added this to the 2.3 milestone Apr 11, 2023
@leonardehrenfried
leonardehrenfried merged commit 51ff01f into opentripplanner:dev-2.x Apr 12, 2023
t2gran pushed a commit that referenced this pull request Apr 12, 2023
@leonardehrenfried
leonardehrenfried deleted the json-logging branch April 12, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Improvement A functional improvement or micro feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON logging

5 participants