@@ -164,7 +164,7 @@ to write logs using the :phpfunction:`syslog` function:
164
164
->type('stream')
165
165
// log to var/logs/(environment).log
166
166
->path('%kernel.logs_dir%/%kernel.environment%.log')
167
- // log *all* messages (debug is lowest level)
167
+ // log *all* messages (LogLevel::DEBUG is lowest level)
168
168
->level(LogLevel::DEBUG);
169
169
170
170
$monolog->handler('syslog_handler')
@@ -255,31 +255,32 @@ one of the messages reaches an ``action_level``. Take this example:
255
255
.. code-block :: php
256
256
257
257
// config/packages/prod/monolog.php
258
+ use Psr\Log\LogLevel;
258
259
use Symfony\Config\MonologConfig;
259
260
260
261
return static function (MonologConfig $monolog): void {
261
262
$monolog->handler('filter_for_errors')
262
263
->type('fingers_crossed')
263
264
// if *one* log is error or higher, pass *all* to file_log
264
- ->actionLevel('error' )
265
+ ->actionLevel(LogLevel::ERROR )
265
266
->handler('file_log')
266
267
;
267
268
268
269
// now passed *all* logs, but only if one log is error or higher
269
270
$monolog->handler('file_log')
270
271
->type('stream')
271
272
->path('%kernel.logs_dir%/%kernel.environment%.log')
272
- ->level('debug' )
273
+ ->level(LogLevel::DEBUG )
273
274
;
274
275
275
276
// still passed *all* logs, and still only logs error or higher
276
277
$monolog->handler('syslog_handler')
277
278
->type('syslog')
278
- ->level('error' )
279
+ ->level(LogLevel::ERROR )
279
280
;
280
281
};
281
282
282
- Now, if even one log entry has an ``error `` level or higher, then *all * log entries
283
+ Now, if even one log entry has an ``LogLevel::ERROR `` level or higher, then *all * log entries
283
284
for that request are saved to a file via the ``file_log `` handler. That means that
284
285
your log file will contain *all * the details about the problematic request - making
285
286
debugging much easier!
@@ -350,13 +351,14 @@ option of your handler to ``rotating_file``:
350
351
.. code-block :: php
351
352
352
353
// config/packages/prod/monolog.php
354
+ use Psr\Log\LogLevel;
353
355
use Symfony\Config\MonologConfig;
354
356
355
357
return static function (MonologConfig $monolog): void {
356
358
$monolog->handler('main')
357
359
->type('rotating_file')
358
360
->path('%kernel.logs_dir%/%kernel.environment%.log')
359
- ->level('debug' )
361
+ ->level(LogLevel::DEBUG )
360
362
// max number of log files to keep
361
363
// defaults to zero, which means infinite files
362
364
->maxFiles(10);
0 commit comments