Skip to content

Channel not used when calling function outside of class #479

Description

@baptistebisson

In my commands, I want loggers to log into the file console.log

Here is my monolog.yaml conf:

when@prod:
    monolog:
        handlers:
            console:
                type: stream
                level: debug
                path: "%kernel.logs_dir%/console.log"
                channels: console
            console-error:
                type: stream
                level: error
                path: "%kernel.logs_dir%/console-error.log"
                channels: console
            info:
                type: stream
                path: "%kernel.logs_dir%/info.log"
                level: info

In my command I've added this: #[WithMonologChannel('console')]

Every log in my command are correctly logged to console.log but every time I call a function outside my command class, the log is logged in info.log.

The issue is that I don't want to add #[WithMonologChannel('console')] in my other class since it's used by other services.

Is there any way to propagate the channel along called functions ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions