---
title: Capturing logs
description: Send application logs from PHP and Laravel applications to Honeybadger Insights.
url: https://docs.honeybadger.io/lib/php/insights/capturing-logs/
---

You can send your application logs to Insights either by sending them to Honeybadger from your [infrastructure](https://docs.honeybadger.io/guides/insights/integrations/log-files/) **or** if you are using Monolog, you can register Honeybadger’s `LogEventHandler` class as a handler:

```php
$logger = new Monolog\Logger('my-logger');
$honeybadger = Honeybadger\Honeybadger::new([
    'api_key' => 'my-api-key'
]);
$logger->pushHandler(new Honeybadger\LogEventHandler($honeybadger));
$logger->info('An info message');
$logger->info('An info message with context data', ["some-key" => "some-value"]);
$logger->error('An error message');
```

You can send an optional second argument to the `LogEventHandler` constructor to specify the minimum log level to be sent to Honeybadger. The default is `Monolog\Logger::INFO`.

```php
new Honeybadger\LogEventHandler($honeybadger, Monolog\Logger::DEBUG);
```

This will send all log messages to Insights, where they will be displayed in the [Insights](https://www.honeybadger.io/tour/logging-observability) section of your dashboard.

## Using Laravel or Lumen

If you are using Laravel or Lumen, [register a custom channel](https://laravel.com/docs/11.x/logging#creating-custom-channels-via-factories) in your `config/logging.php`, making use of the `HoneybadgerLogEventDriver`:

config/logging.php

```php
    'channels' => [
        // ...
        'honeybadger' => [
            'driver'  => 'custom',
            'via' => Honeybadger\HoneybadgerLaravel\HoneybadgerLogEventDriver::class,
            'name' => 'honeybadger',
            'level' => 'info',
        ],
    ],
```

Now you can write log messages as normal with Laravel’s log facade, and they’ll show up in Honeybadger Insights:

```php
Log::channel('honeybadger')->info('An info message');
Log::channel('honeybadger')->error('An error message with context', ["some-key" => "some-value"]);
```

Add this custom channel to your default stack and voilà, all your log messages will appear in Honeybadger Insights:

config/logging.php

```php
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'honeybadger'],
            'ignore_exceptions' => false,
        ],
        // ...
    ],
```

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
