0

I am trying to manage logs configs on a per-bundle basis within symfony (3.4).

In more detail, I am working with an application with many bundles and want to make logs easier to identify. The best way that I have found to do this so far is to include a context in the log line.

I know that I can achieve this as so:

$this->logger->error("this is an error", ["bundle"=>"content_bundle"]);

But this would mean going through every existing logger call and modifying to look like above (The joys of hindsight!)

Is there a way that I can configure this per bundle? I was thinking something like this in the config.yml for each bundle:

monolog:
  handlers:
    syslog_handler:
      context:
        - bundle: "content_bundle"

Clearly, this doesn't work but maybe there is similar?

Wildcard27
  • 1,437
  • 18
  • 48

1 Answers1

0

You can separate this logs by channels: How to Log Messages to different Files

And then you should tag every class, that write logs with channel-name tag: Creating your own Channel

Timur
  • 1