0

I'm using monolog to log API requests. Some of those log messages include fairly large payloads. I would like to keep the general verbosity, but cut off all lines at 300 characters. Is it possible to configure monolog accordingly?

didi_X8
  • 5,018
  • 10
  • 42
  • 46
  • It is possible to limit the size of context (e.g. your payload) BEFORE you pass it to monolog. – Matiss Jul 20 '15 at 15:41

1 Answers1

3

You can use a processor in order to do it (https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#adding-extra-data-in-the-records) :

$logger->pushProcessor(function ($record) {
    $record['message'] = substr($record['message'],0,300);
    return $record;
});
griotteau
  • 1,772
  • 12
  • 15