Reputation: 130
In Symfony 3 is there anyway i can write all errors to logs on production without setting the debug mode on? Errors would include http 500 errors or application errors or the php errors which are silenced due to the error flag set to false on production.
The current log config for production is
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: info
channels: [!request, !event, !translation, !kernel, !security, !php, !snc_redis]
php:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%_php.log"
level: warning
channels: [php]
Upvotes: 9
Views: 21043
Reputation: 17166
You could use the default production settings (taken from the monolog-bundle recipe) for this:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
What happens with this configuration is that Monolog buffers all messages during a request, but only writes them to the log when an error appears. This way you will not "flood" your logs with noisy debug and info messages all the time. You only get full log information when there was an error during a request.
Upvotes: 14