Michael Heumann
Michael Heumann

Reputation: 120

Laravel 8: Custom logging overriding error_log

I have a Laravel/Lumen 8 API that in the background includes legacy standard PHP code to provide some functionality. This code is also used in parallel by a separate application, so it has to remain compatible with a non-Laravel environment.

My problem is regarding logging. The Laravel part of the API obviously uses the Laravel logging mechanism to write daily log files to storage/logs. But the legacy code writes errors to the PHP error log file via the command error_log, and I can't see when an error happens back there in the Laravel file, and also the messages are not being written to the var/log/apache2 folder when called from Laravel.

I know there is a logging driver called errorlog in Laravel, but I think it works the other way around, letting me write via Log::debug() to the PHP log file. What I need, is a way to make the messages written by the error_log() function write to the Laravel log file, without having to modify all the error_log calls in the legacy code.

Is there a way to do this?

Upvotes: 1

Views: 80

Answers (0)

Related Questions