Skip to content

Conversation

amadeann
Copy link
Contributor

There's no "null" driver for logging. There is only a "null" channel.

There's no "null" driver for logging. There is only a "null" channel.
@browner12
Copy link
Contributor

Before we get rid of this, can we add a section to discuss how to send logs to the "null" stack? It's still helpful information to know.

@amadeann
Copy link
Contributor Author

@browner12
I added this in my AppServiceProvider to get the null log functionality working:

use Monolog\Handler\NullHandler;
use Monolog\Logger as MonologLogger;

...

if (($logManager = $this->app->make('log')) instanceof LogManager) {
    $logManager->extend('null_driver', function ($app, array $config) {
        return new MonologLogger('null_driver', [
            new NullHandler,
        ]);
    });
}

but I think this is too much of a workaround for the docs. And then, having the driver named "null" is problematic, since there's no way I know of to define string null in .env file.

@browner12
Copy link
Contributor

I wasn't suggesting a code change, just a docs blurb about how to use the "null" channel.

@amadeann
Copy link
Contributor Author

I am not sure what note would be appropriate. This section
https://laravel.com/docs/10.x/logging#writing-to-specific-channels
already covers the topic of logging to a specific channel.

@taylorotwell taylorotwell merged commit f337900 into laravel:10.x Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants