use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('app'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::CRITICAL)); // add records to the log $log->critical('An unexpected error occurred!');
// log a critical error error_log('Critical error occurred!', 1, 'admin@example.com', 'Subject: Critical Error');In this example, we use the built-in PHP function `error_log` to log a critical error. The function allows us to specify a recipient email address and a subject line for the error message.