use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('exceptions'); $log->pushHandler(new StreamHandler('exception.log', Logger::WARNING)); try { // some code that might throw an exception } catch (Exception $e) { // log the exception $log->error($e->getMessage()); }In this example, we first create a new `Logger` instance and give it a name ("exceptions"). We then add a `StreamHandler` to write log messages to a file named `exception.log`. Finally, we wrap some code in a `try`-`catch` block and log any exceptions that are thrown using the `error()` method. The `Monolog` library is a popular choice for PHP logging due to its flexibility and ease of use. It allows developers to log messages to different channels, use different handlers (e.g. sending logs to email or Slack), and format log messages using different processors.