0

I am trying to access the log output content in Laravel, before being written to a file. I am searching for in on laravel/framework/src/Illuminate/Log/LogManager.php and the monolog/monolog package but do not find any related method for it.

I mean there should be a method to be called and give the output content that is going to be written on the log file but NOT writing to the file.

Suppose we want to write Log::info("Hello") and the output file will be written on the log file like this: [2021-08-25 06:04:51] local.INFO: Hello.

I am looking for a method to give me the content of the written log message [2021-08-25 06:04:51] local.INFO: Hello but not write this content on the log file. Is there a method for it on laravel or monolog or should I write it myself?

Majid Alaeinia
  • 962
  • 2
  • 11
  • 27
  • Can you implement your own version of a LogWriter? – Honk der Hase Aug 25 '21 at 06:20
  • I am actually writing a package that formats the log file for the filebeat (elasticsearch) and the output is a JSON with a predefined schema that uses middleware and other stuff to format the output file. I just think there should be a method to get the output content before writing it to the file. – Majid Alaeinia Aug 25 '21 at 06:26
  • @LarsStegelitz I think it should be the `write` method on the `monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php` file. Another way is to use something like `X-Debug` and follow it by debugging tool. – Majid Alaeinia Aug 25 '21 at 06:41

0 Answers0