php-docs-samples
php-docs-samples copied to clipboard
Symfony app engine standard - monolog
Where can I see the 'google_cloud' monolog handler below used?
To me it seems whether it's there or not the result is the same for me.
When an uncaught exception is hit, I do see the error report in the GCP console but that happens even without the 'google_cloud: ' section.
google_cloud:
type: service
id: monolog_psr_batch_logger
My Full File:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: grouped
excluded_http_codes: [ { 403: [ '^/user', '^/admin' ] }, { 404: [ '^/' ] }, { 405: [ '^/' ] } ]
grouped:
type: group
members: [ streamed, deduplicated ]
streamed:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: info
console:
type: console
process_psr_3_messages: false
channels: [ "!event", "!doctrine" ]
deduplicated:
type: deduplication
handler: email_developer
email_developer:
# https://symfony.com/doc/current/logging/monolog_email.html
type: symfony_mailer
from_email: '[email protected]'
to_email: '[email protected]'
subject: 'Error: %%message%%'
level: debug
formatter: monolog.formatter.html
headers: [ 'Content-Type: text/html' ]
google_cloud:
type: service
id: monolog_psr_batch_logger
services:
monolog_psr_batch_logger:
class: Monolog\Handler\PsrHandler
arguments: [ '@google_cloud_stackdriver_psr_batch_logger' ]
google_cloud_stackdriver_psr_batch_logger:
class: Google\Cloud\Logging\PsrLogger
factory: [ 'Google\Cloud\Logging\LoggingClient', 'psrBatchLogger' ]
arguments: [ 'myprojectxxx-logs' ]
According to the symfony docs for adding a custom handler, this is how it's done. If it's not working, I'd have to debug further, but this looks accurate to me.