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