-
Notifications
You must be signed in to change notification settings - Fork 284
Open
Description
What data should be put into structured logging attributes? Everything? Or only unimportant meta-information? If everything, should text message duplicate data already included in KV attributes?
// 1. only minor meta-information
log::error!(target: "pusher", "Push for client {uuid} failed: {err}");
// 2. everything, text message duplicates data
log::error!(target: "pusher", uuid:?, err:%; "Push for client {uuid} failed: {err}");
// 3. everything, text message doesn't include data logged into kv attributes
log::error!(target: "pusher", uuid:?, err:%; "Push for client failed");- This option seems inferior to me, as you can't effectively filter log entries by error or client.
- Some loggers, notably,
env_loggerin its default configuration, will print both message and KVs to the console, which is redundant and ugly. However, it works fine forsystemd-journal-logger:journalctlprints only the text message by default (+ timestamp). And you can also filter by KV attributes, as they're stored as custom journal fields. - Some loggers, notably,
systemd-journal-logger, will store only the text message intoMESSAGEjournal field, and store the KVs as custom journal fields.journalctlwill only show the text, and important error details can only be retrieved withjournalctl -o verbose, and its output is too noisy to use for typical log-reading activities. In contrast, this record is rendered perfectly byenv_logger:message key1=value1 key2=value2 ...
I think log is missing concrete guidelines regarding stuctured logging usage. Although output format is configurable in many loggers, it isn't in systemd-journal-logger, and you're still out of luck if combine different libraries that log using different conventions.
/cc @swsnr
Metadata
Metadata
Assignees
Labels
No labels