1

I'm trying to set up a console command in Symfony2 so that it logs to the console in my dev environment, but to a logfile in prod.

so my config_prod.yml has this:

monolog:
    handlers:
        payment:
            type:  stream
            path:  %kernel.logs_dir%/payment.log
            channels: payment

while my config_dev.yml uses this:

monolog:
    handlers:
        console:
            type:   console
            channels: payment

and the service is defined in services.yml like this:

payment_manager:
    class:      My\Bundle\Service\PaymentManager
    arguments:  [@doctrine.orm.entity_manager, @logger]
    tags:
        - { name: monolog.logger, channel: payment }

To my surprise, this does squat nothing. Output goes to app/logs/dev.log instead of the console. Why?

Mick
  • 30,759
  • 16
  • 111
  • 130
Tom
  • 2,688
  • 3
  • 29
  • 53
  • Many days later, I'm still completely lost, except that it appears to me that the console handler isn't working at all. Is that possible? – Tom Jun 01 '14 at 14:42

1 Answers1

8

It turns out that "console" doesn't actually mean console at all, it means "browser's javascript console".

If you came here because you have the same question, here's how to do it:

    output:
        type:       stream
        path:       php://stdout
        level:      info
Tom
  • 2,688
  • 3
  • 29
  • 53