The minimal log level can be changed by setting the SHELL_VERBOSITY environment variable:
ERROR(-1), NOTICE(1), INFO(2), DEBUG(3)
1. Logging a Message
- inject the default logger in your controller
2. Monolog
- create and store log messages in a variety of different places
- trigger various actions
3. Where Logs are Stored
- var/log/dev.log (dev environment)
- var/log/prod.log (prod environment)
4. Handlers: Writing Logs to different Locations
# config/packages/prod/monolog.yaml
monolog:
handlers:
# this "file_log" key could be anything
file_log:
type: stream
# log to var/log/(environment).log
path: "%kernel.logs_dir%/%kernel.environment%.log"
# log *all* messages (debug is lowest level)
level: debug
syslog_handler:
type: syslog
# log error-level messages and higher
level: error
5.Handlers that Modify Log Entries
# config/packages/prod/monolog.yaml
monolog:
handlers:
filter_for_errors:
type: fingers_crossed
# if *one* log is error or higher, pass *all* to file_log
action_level: error
handler: file_log
# now passed *all* logs, but only if one log is error or higher
file_log:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
# still passed *all* logs, and still only logs error or higher
syslog_handler:
type: syslog
level: error
6. All Built-in Handlers
Monolog comes with many built-in handlers for emailing logs, sending them to Loggly, or notifying you in Slack.
7. How to Rotate your Log Files
- rotating_file handler