Levels
Flare uses Monolog log levels throughout its logging system. The following levels are available, from most to least severe:
| Level | Description |
|---|---|
Level::Emergency |
System is unusable |
Level::Alert |
Action must be taken immediately |
Level::Critical |
Critical conditions |
Level::Error |
Error conditions |
Level::Warning |
Warning conditions |
Level::Notice |
Normal but significant condition |
Level::Info |
Informational messages |
Level::Debug |
Debug-level messages |
When you set a minimal log level, only logs at that level or above (more severe) will be collected.
Where log levels can be configured
There are two places where you can configure log levels, each controlling a different part of the logging system.
Standalone log shipping
When enabling log collection, you can set a minimal level for logs that are shipped to Flare as standalone entities:
use Monolog\Level;
$config->log(true, minimalLevel: Level::Warning);
When set, only logs at Warning or above will be sent to Flare. When null (the default), all log levels are sent.
This is the primary level gate. If a log doesn't pass this threshold, it won't be recorded at all, meaning it also won't be available for inclusion with error reports.
Monolog handler
When using the FlareLogHandler with a Monolog logger instance, you can set the handler's level threshold:
$monolog->pushHandler(new FlareLogHandler($flare->logger, Level::Warning));
This acts as a gate before logs reach the Flare logger. By default, the handler accepts all levels (Level::Debug).
Logs with errors
When an error occurs, recent log entries are included alongside the error report. You can set a separate minimal level for these logs:
use Monolog\Level;
$config->collectLogsWithErrors(
minimalLevel: Level::Warning,
);
The default level is Level::Info. This level only filters logs that were already recorded by the logger, it cannot include logs that were filtered out by the standalone log level.
How the levels interact
The standalone log level is the primary gate. It determines which logs are recorded at all. The logs-with-errors level is a secondary filter that only applies when attaching logs to error reports.
For example, if you set the standalone level to Level::Warning and the logs-with-errors level to Level::Info, the logs-with-errors level has no effect, Info logs were never recorded in the first place.
As a rule of thumb: the logs-with-errors minimal level should always be equal to or higher than the standalone log level.