use Monolog\Logger; use Monolog\Handler\StreamHandler; $logger = new Logger('name'); $logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); // logs a warning message $logger->warning('Foo');
use Illuminate\Support\Facades\Log; // logs an error message Log::error('Something went wrong!');In both examples, the code is designed to work with any package that implements the LoggerInterface. In Example 1, the Monolog library is a popular PHP logging library that supports the LoggerInterface. In Example 2, the Laravel framework provides a logging facade that supports the LoggerInterface.