Skip to content

enable or disable handlers with env vars #274

Open
@mathroc

Description

@mathroc

Hi,

we deploy a docker image in production, this image contains the source code, cache and assets (in short, we run composer install in the Dockerfile)

the problem is that logs are pushed to logstash with the gelf handler and this can't work in the image build process (we don't want to log to logstash at that point anyway)

I would like to enable a StreamHandler when in the docker build and the GelfHandler when the image is deployed, ideally the config would look something like this:

parameters:
  env(LOG_TO_LOGSTASH): true
  env(LOG_TO_STDERR): false

monolog:
    handlers:
        logstash:
            type: gelf
            level: warning
            ...
            enabled: '%env(bool:LOG_TO_LOGSTASH)%'
        main:
            type:  stream
            level: warning
            path:  "php://stderr"
            enabled: '%env(bool:LOG_TO_STDERR)%'

and in the Dockerfile I could do:

...

RUN LOG_TO_LOGSTASH=false LOG_TO_STDERR=true composer install

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions