Log routing according to metadata
Opened this issue · 2 comments
In other logging settings, I've found value in being able to redirect certain log statements to individual files e.g.: in one application that manages 3 identical serial devices- my logging is configured to create logs <device1>.log
, <device2>.log
, <device3>.log
, each with the serial traffic for just one device, rather than an interleaved log that has UI considerations, DB changes, etc.
Has this idea already been floated? Currently, it looks like a config stanza is needed per file; would it be possible to have a single config stanza create/append to multiple files, and specify a metadata wildcard in the :path
key, like such:
config :logger, :serial_devices,
path: "/path/to/logs/device_$metadata[$device_id].log",
level: :info
A different, but related capability: being able to deliver messages to a log based on the presence of a metadata key:
config :logger, :ui_logging,
path: "/path/to/logs/ui.log"
level: :info,
required_metadata: [application: :ui] # or a custom key
There is probably a clever syntax for specifying the filter better than what I have- while I'm suggesting a syntax to be constructive, I'm not wedded to it, and I think there's tons of room for improvement.
Generally, what's the reaction to this idea? Is it something the community would be open to including in this project?
Looks like this has been done and merged, any chance on a new hex.pm version with it? :-)
@meyercm Is this issue resolved?