Merge pull request #30727 from leboncoin/feat-root-logger-service-overrides

feat(backend-defaults): add backend.logger configuration options
This commit is contained in:
Patrik Oldsberg
2025-09-16 10:03:41 +02:00
committed by GitHub
14 changed files with 713 additions and 8 deletions
@@ -13,6 +13,51 @@ If you want to override the implementation for logging across all of the backend
## Configuring the service
### Configuration parameters
The Root Logger Service can be configured with the `backend.logger` section of your `app-config.yaml`.
The following parameters are available:
- `level` (string, optional): Sets the global log level. Possible values are `debug`, `info`, `warn`, or `error`. Only messages at or above this level will be logged. This can also be set via the `LOG_LEVEL` environment variable, which takes precedence. Defaults to `info`. See [Modifying the log level](#modifying-the-log-level).
- `meta` (object, optional): Additional metadata to include with every log entry.
- `overrides` (array, optional): Allows to specify logger overrides for specific plugins or messages. Each override can match on plugin names, message patterns, or any field contained in the log, and set a custom log level for those matches.
Log level overrides are useful for controlling the volume of logs generated in Backstage.
They allow you to apply a global log level, `info` for example, while setting a stricter level, such as `warn`, for specific verbose plugins.
The reverse is also possible: you can set a global log level of `warn` while enabling a more detailed level, such as `debug`, for certain logs.
Example:
```yaml
backend:
logger:
meta:
env: prod # Every log message will have `env="prod"`
level: info # Set the global log level to info (the default)
overrides:
# Set the log level to 'debug' for the catalog plugin logs
- matchers:
plugin: catalog
level: debug
# Ignore 'info' incoming HTTP requests logs from the rootHttpRouter service
- matchers:
service: rootHttpRouter
type: incomingRequest
level: warn
# Ignore logs starting with "Task worker starting", unless they're warnings or errors
- matchers:
message: ['/^Task worker starting/']
level: warn
```
### Modifying the log level
The available log levels, in order of decreasing verbosity, are:
@@ -21,7 +66,6 @@ The available log levels, in order of decreasing verbosity, are:
- `info`: General information about the application's operation. This is the default level.
- `warn`: Indicates potential issues or situations that may require attention.
- `error`: Indicates errors that have occurred but may not necessarily prevent the application from continuing.
- `critical`: Indicates critical errors that require immediate attention and likely prevent the application from functioning correctly.
The verbosity of the logging can be controlled by setting the log level. The log level determines the minimum severity level of events that will be output to the console. For example, if the log level is set to `info`, events with a severity level of `debug` will be ignored.