esono/chameleon-standard-logging-bundle
Defines standard logging for Esono chameleon projects
Requires
- chameleon-system/chameleon-base: ~7.1.0
README
This bundle provides a formatter class which produces a log format suitable for logging to a server with fluentbit.
Its usage (config in project) is visible in the example config (logger-prod.yaml).
It also defines a number of processors (automatically active) to add additional informations to log messages:
- psr
- web
- introspection
- memory usage
- process id
- Chameleon bits (pagedef, request type)
- demote routing messages to level DEBUG
Additionally it has an error listener (extends the standard Symfony exception listener) that demotes not found messages (401, 403, 404) to level NOTICE. And there is a processor which demotes route messages ("Matched route") to level DEBUG.
Best Practice Logging
In dev environments, everything from debug level onward should be logged. In prod environments everything from info level onward should be logged.
A fingers_crossed logger with passthru_level is usually not a good idea - at least not for cases where there is much logged, for example an import:
It buffers all log messages and only handles all of them at the end of a request or when an error is triggered. This can lead
to problematic behavior and is generally unexpected.
There are example configurations in ./Resources/config.
NOTE You can set the minimum logging level to notice if there is too much info logging in your project that shouldn't show up in a prod log.
The following parameter has to be defined:
parameters:
# The fluent bit connection string. On an ESONO k8s setup, fluent bit will be available via localhost on the standard fluent bit port.
# Example for k8s: esono_chameleon_standard_logging.connection_string: tcp://localhost:5170
esono_chameleon_standard_logging.connection_string: tcp://my-fluent-bit:fluent-bit-port
Disabling Handlers for a specific environment (e.g. init containers)
If you want to disable all configured handlers in a specific environment, you can do so by
setting the ESONO_STANDARD_LOGGING_REPLACE_HANDLER to 1. This can be useful for environments
without the required supporting infrastructure for handlers (e.g. init containers, that are executed
before fluentbit is running).
If ESONO_STANDARD_LOGGING_REPLACE_HANDLER = 1 is set, then all handlers will be replaced by a simple
ErrorLogHandler which will write all log messages in to the PHP error log.