Skip to content

Commit

Permalink
[6.x] Allow configurable emergency logger (#30873)
Browse files Browse the repository at this point in the history
* Updated createEmergencyLogger

This allows for an emergency logger channel config item in config/logging.php

Use case: Serverless environment or Docker container without persistent storage. If main logger fails, logs may be lost. This will help prevent that by allowing us to specify stderr or stdout as the logger's path. (This will allow us to forward logs onto an ELK stack etc.)

* Update LogManager.php

* Not allowed to use the storage_path helper outside of Foundation

* Revert change to doc
  • Loading branch information
Michael-Stokoe authored and taylorotwell committed Dec 18, 2019
1 parent 58a39ab commit dba030b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Illuminate/Log/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,17 @@ protected function parseTap($tap)
*/
protected function createEmergencyLogger()
{
return new Logger(new Monolog('laravel', $this->prepareHandlers([new StreamHandler(
$this->app->storagePath().'/logs/laravel.log', $this->level(['level' => 'debug'])
)])), $this->app['events']);
$config = $this->configurationFor('emergency');

$handler = new StreamHandler(
$config['path'] ?? $this->app->storagePath().'/logs/laravel.log',
$this->level(['level' => 'debug'])
);

return new Logger(
new Monolog('laravel', $this->prepareHandlers([$handler])),
$this->app['events']
);
}

/**
Expand Down

0 comments on commit dba030b

Please sign in to comment.