logger_file_backend icon indicating copy to clipboard operation
logger_file_backend copied to clipboard

Log routing according to metadata

Open meyercm opened this issue 9 years ago • 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?

meyercm avatar May 24 '16 01:05 meyercm

Looks like this has been done and merged, any chance on a new hex.pm version with it? :-)

OvermindDL1 avatar Jul 11 '16 22:07 OvermindDL1

@meyercm Is this issue resolved?

isaacsanders avatar Nov 12 '18 21:11 isaacsanders