I suggest stick with laravels error handler, you can still have custom messages.
Oct 10, 2024
3
Level 1
Laravel will not use my custom log class
To make the Log facade methods accept a custom message class, which includes a message ID, I created a custom log class. It extends the Log facade. Calling Logger::error() works, but I want to keep using the normal Log::error() call.
I cannot get Laravel to use this logger. In a service provider I tried to register the logger in several ways in the register() and boot() methods:
// Use the service alias.
AliasLoader::getInstance()->alias('log', Logger::class);
// Uppercase first letter.
AliasLoader::getInstance()->alias('Log', Logger::class);
// Put it in the container, using the name that Laravel puts it under.
app()->bind(\Illuminate\Log\LogManager::class, Logger::class);
With every option I tried calls to Log::error() is still handled by the default logger, not my implementation.
Does anyone know to get Laravel to use my custom logger?
Please or to participate in this conversation.