简体   繁体   中英

symfony dev.log in prod

I've similar quesitons here in stackoverflow but haven't seen an answer.

I currently have dev.log and prod.log in my production environment and I don't understand why. I should only have prod.log.

My dev.log only contains this (repeated every 2 minutes):

[2017-04-21 17:50:02] event.DEBUG: Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". [] []
[2017-04-21 17:50:02] doctrine.DEBUG: SELECT e0_.id AS id0, e0_.name AS name1, e0_.progress AS progress2, e0_.path AS path3, e0_.data AS data4, e0_.created_at AS created_at5, e0_.updated_at AS updated_at6, (SELECT COUNT(e1_.id) AS dctrn__1 FROM export e1_ WHERE e1_.progress > 0 AND e1_.progress < 100) AS sclr7, e0_.organization_id AS organization_id8, e0_.owner_id AS owner_id9 FROM export e0_ WHERE e0_.progress = 0 HAVING sclr7 = 0 LIMIT 1 [] []
[2017-04-21 17:50:02] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []

Here are my config_dev.yml and config_prod.yml monolog configs:

config_dev:

monolog:
  handlers:
    main:
      type:  stream
      path:  %kernel.logs_dir%/%kernel.environment%.log
      level: debug

config_prod:

monolog:
  handlers:
    main_critical:
      type:         fingers_crossed
      action_level: critical
      handler:      buffered_critical
    buffered_critical:
      type:    buffer
      handler: swift_critical
    swift_critical:
      type:       swift_mailer
      from_email: %error_mail_sender%
      to_email:   %error_mail_recipients%
      subject:    An error occurred
      level:      debug
    main_error:
      type:         fingers_crossed
      action_level: error
      handler:      grouped_error
    grouped_error:
      type:    group
      members: [streamed]
    streamed:
      type:  stream
      path:  "%kernel.logs_dir%/%kernel.environment%.log"
      level: debug

I notice the log shows that a console command happens, and there's a cronjob which runs a command every two minutes, but I don't know why this goes to dev.log...

Thanks a lot for your help, Cheers

By Default, Symfony Commands are executed in the Dev environment that's why it stores all kinds of logs in the dev.log file using your dev environment configurations for logging.

you need to use --env=prod flag with your Symfony command to explicitly tell Symfony to run this command in prod environment.

NOTE: so if you are running command via cron add the --env=prod flag at the end of a command.

this answer is an explanation of @cerad comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM