Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Schema Comparison between Structured Logging Libraries

The goal of this document is to summarize the differences between various structured logging libraries, in order to encourage a discussion so that a consensus can be reached for a common format.

Please use the GitHub issues for discussion, and submit GitHub Pull requests to add/fix the information in the tables.

Message and Payload

Behold the following logging command that you might find in an application. There is a "message" string, and a "payload" object:

logger.info("Hello World", {"animal": "cat", "numLegs": 4})
^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Message Payload object

Some libraries merge the payload object with the root object, so the event will look like this:

{
"timestamp": "2018-06-18T23:16:45.000Z",
"message": "Hello World",
"animal": "cat",
"numLegs": 4
}

While other libraries nest the payload object beneath some key, with a result like this:

{
"timestamp": "2018-06-18T23:16:45.000Z",
"message": "Hello World",
"data": {
"animal": "cat",
"numLegs": 4
}
}
LibraryMessage JSON KeyPayload Object JSON Key
bunyan (JavaScript)msgMerged with root
katip (Haskell)msgdata
logrus (Go)msgMerged with root
logstashmessageMerged with root
ougai (Ruby)msgMerged with root
pygogo (Python)messageMerged with root
roarr (JavaScript)messagecontext
semantic logger (Ruby)messagepayload
serilog (C#)@m / @mtMerged with root
slog (Rust)msgMerged with root
structlog (Python)msgHELP NEEDED

Timestamp JSON Key and format

All libraries automatically add a timestamp to all events.

LibraryTimestamp JSON KeyTimestamp format
bunyan (JavaScript)timeISO 8601
katip (Haskell)atISO 8601
logrus (Go)timeISO 8601
logstashtimestamp / @timestampISO 8601 / varies
ougai (Ruby)timeISO 8601
pygogo (Python)timeISO 8601
roarr (JavaScript)timeEpoch milliseconds
semantic logger (Ruby)timestampISO 8601
serilog (C#)Timestamp / @tISO 8601
slog (Rust)tsISO 8601
structlog (Python)timestampISO 8601

Log Level

All libraries require that that all events are tagged with a level, chosen from a pre-defined list of available levels.

Log Level JSON Key

LibraryLog Level JSON Key
bunyan (JavaScript)level
katip (Haskell)sev
logrus (Go)level
logstashHELP NEEDED
ougai (Ruby)level
pygogo (Python)level
roarr (JavaScript)context.logLevel
semantic logger (Ruby)level
serilog (C#)Level / @l
slog (Rust)level
structlog (Python)level

Available Log Levels

LibraryVERBOSETRACEDEBUGINFONOTICEWARNINGERRORCRITICALALERTFATALPANICEMERGENCY
bunyan (JavaScript)N/A102030N/A4050N/AN/A60N/AN/A
katip (Haskell)N/AN/ADebugInfoNoticeWarningErrorCriticalAlertN/AN/AEmergency
logrus (Go)N/AN/AdebuginfoN/AwarningerrorN/AN/AfatalpanicN/A
logstashHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDED
ougai (Ruby)N/A102030N/A4050N/AN/A60N/AN/A
pygogo (Python)N/AN/ADEBUGINFON/AWARNINGERRORCRITICALN/AN/AN/AN/A
roarr (JavaScript)N/A102030N/A4050N/AN/A60N/AN/A
semantic logger (Ruby)N/AtracedebuginfoN/AwarnerrorN/AN/AfatalN/AN/A
serilog (C#)VerboseN/ADebugInformationN/AWarningErrorN/AN/AFatalN/AN/A
slog (Rust)N/ATRACEDEBUGINFON/AWARNERRORCRITICALN/AN/AN/AN/A
structlog (Python)N/AN/AdebuginfoN/AwarningerrorcriticalN/AN/AN/AN/A

System Context Data

Some libraries automatically add additional fields to all events (such as process ID and thread ID) and/or allow you to configure a few pre-determined global fields suchs the current environment and application.

LibraryEnvironmentApplicationNamespacePackageMachine HostnameProcess IDThread ID
bunyan (JavaScript)N/AN/AN/AN/AhostnamepidN/A
katip (Haskell)envapp (Array of strings)ns (Array of strings)N/Ahostpidthread
logrus (Go)N/AN/AN/AN/AN/AN/AN/A
logstashHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDEDHELP NEEDED
ougai (Ruby)N/AappN/AN/AhostnamepidN/A
pygogo (Python)N/AN/AN/AN/AN/AN/AN/A
roarr (JavaScript)N/Acontext.applicationcontext.namespacecontext.packagecontext.hostnameN/AN/A
semantic logger (Ruby)environmentapplicationN/AN/Ahostpidthread
serilog (C#)N/AN/AN/AN/AN/AN/AN/A
slog (Rust)N/AN/AN/AN/AN/AN/AN/A
structlog (Python)N/AN/AN/AN/AN/AN/AN/A

HTTP Request Context Data

Logging of HTTP requests is very common. Let's figure out a common format for HTTP method, host, url, headers, remote IP, remote IP geo-lookup, response status code, response size, etc...

!!! TODO !!!

About

Mission: Agree on a common format for application structured logs

Resources

Stars

27 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors