use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::ERROR)); // add records to the log $log->error('Error message');
use Psr\Log\LogLevel; use Psr\Log\LoggerInterface; // create a log channel $log = new LoggerInterface(); // add records to the log $log->log(LogLevel::WARNING, 'Warning message');In this example, the PSR log is instantiated and a warning message is logged using the LogLevel::WARNING constant. Overall, PHP static loggers are crucial for debugging and monitoring applications, and there are many different options available for developers to choose from depending on their needs.