Disable "notified event" message from DEBUG log - symfony

It's a painfull job to analyse my actual dev log because the huge amount of "event.DEBUG: Notified event ..." messages. Anyone knows how can I disable the dispatcher notification logs?
Thanks in advance!

You can use channels to ignore events.
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: "!event"
see details here : http://symfony.com/doc/current/cookbook/logging/channels_handlers.html#yaml-specification

The easiest way to accomplish all of this is splitting the various logging channels and levels in app/config/config_dev.yml
monolog:
handlers:
event_all:
bubble: false
action_level: DEBUG
type: stream
path: %kernel.logs_dir%/%kernel.environment%_event_all.log
channels: event
event_errors:
action_level: ERROR
type: stream
path: %kernel.logs_dir%/%kernel.environment%_event_errors.log
channels: event
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: DEBUG
Best guide for how to separate different channels and error levels is here:
http://symfony.com/doc/current/cookbook/logging/monolog.html
Also, see here for my personal recommendations for production log separation:
Symfony2 - Doctrine log

Related

Symfony custom channel / logger

I am trying to add a simple logger channel "brp" with the following SF6.2-DEV environment:
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
- brp
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: info
channels: ["!event","!doctrine","!console"]
Few things, I need this one channel to log to the database into a table I specify, also I am only interested in info, warning and errors captured in the "brp" channel.
I've managed to get access to that channel with a simplified config:
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
- brp
But this logs to a file, and includes all the errors levels, and so on.
TIA
You need to do someting like this, according to the official doc here :
monolog:
channels: [deprecation,brp]
handlers:
deprecation:
type: stream
channels: [deprecation]
level: error
path: '%kernel.logs_dir%/deprecated.log'
brp:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: info
channels: ["!event","!doctrine","!console"]

Symfony 3 Console exception logging only displayed on console

In our Symfony 3 app all logging from console commands (e.g. when there's an exception) are nicely formatted and displayed to the screen... which when dealing with cron jobs in production mode is completely useless.
All exception logging from HTTP requests are routed through log files on the server and reports sent to us via Swifmail (as per https://symfony.com/doc/3.4/logging/monolog_email.html)
I need to get logs from console commands treated the same as logs from HTTP requests but the Symfony documentation seems to ignore this scenario?
monolog:
handlers:
main:
type: fingers_crossed
action_level: critical
handler: grouped
grouped:
type: group
members: [streamed, deduplicated]
streamed:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
deduplicated:
type: deduplication
handler: swift
swift:
type: swift_mailer
level: debug
formatter: monolog.formatter.html
content_type: text/html
console:
type: console
process_psr_3_messages: false
Any ideas?????
-- Edit --
It turns out that Symfony logs console exceptions at Monolog's error(400) level but we have monolog.handlers.main.action_level set to critical(500).
So, it seems, that I can either patch Symfony\Component\Console\EventListener\ErrorListener to call $this->logger->addCritical instead of $this->logger->error or take the config level down from critical to error and put up with getting error reports for all the HTTP 4?? errors too.

Symfony 3: No prod or dev logs, Authentication request could not be processed due to a system problem

I am getting a generic error ("Authentication request could not be processed due to a system problem") while logging in. I understand that the reasons could be numerous, but I am getting nothing in the prod logs. How do I get an message in the log files or alternately, how can I debug this? I am testing against my local environment and so have access to everything. I have deleted all cache(s)
Below is my config_prod.yaml
imports:
- { resource: config.yml }
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
level: info
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
I can get the logs and with it the reason for the failure once I set the action level in the monolog above to "info":
action_level: info
Still, it is quite remarkable that a fatal error disallowing the application from starting is logged by symfony with mere "info" severity.

How to email console errors in symfony

I have configured my app to send emails on exceptions this way (prod/monolog.yaml):
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: grouped
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
grouped:
type: group
members: [nested, deduplicated]
deduplicated:
type: deduplication
handler: swift
swift:
type: swift_mailer
from_email: '%admin_notifier_from%'
to_email: '%admin_notifier_to%'
subject: 'Error'
level: debug
formatter: monolog.formatter.html
content_type: text/html
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
And it works. When I throw an exception in some controller, open url for that controller I get an email with an exception. So emailing works on http level. However it does not on console level. I am using SF v4.2. I found that in recent symfony version console exception logging was added so no need to add error console listener for it. It should work on my version. Actually I see exception messages in log files. But no email. So I decided to add an error listener and log critical message (assuming it should trigger main monolog handler). So I did it. And again, I see my critical message in log file but still no email. So what wrong am I doing? I want to get exception emails on console exceptions.
I triend to replace "deduplicated" handler with "swift" one but it did not help.

How I make log by day in Symfony

community. I need make logs files daily with Symfony4; or push a current date in a yml file. Specifically in monologo.yml.
handlers:
app:
type: stream
path: "%kernel.logs_dir%/system_compact_%kernel.environment%-***date***.log"
channels: ["app"]
Thank a lot.
Use can use "rotating_file" log type:
monolog:
handlers:
main:
type: rotating_file
path: "%kernel.logs_dir%/system_compact_%kernel.environment%.log"
Look at this documentation page: https://symfony.com/doc/current/logging.html#how-to-rotate-your-log-files

Resources