Merge pull request #1598 from flarum/dk/log-rotation

adds log rotation, reducing file size per log file and easier to delete
This commit is contained in:
Franz Liedke 2018-10-10 00:27:39 +02:00 committed by GitHub
commit 08af258f3a

View File

@ -43,7 +43,7 @@ use Illuminate\Mail\MailServiceProvider;
use Illuminate\Validation\ValidationServiceProvider; use Illuminate\Validation\ValidationServiceProvider;
use Illuminate\View\ViewServiceProvider; use Illuminate\View\ViewServiceProvider;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler; use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger; use Monolog\Logger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -219,7 +219,7 @@ class InstalledSite implements SiteInterface
private function registerLogger(Application $app) private function registerLogger(Application $app)
{ {
$logPath = $app->storagePath().'/logs/flarum.log'; $logPath = $app->storagePath().'/logs/flarum.log';
$handler = new StreamHandler($logPath, Logger::INFO); $handler = new RotatingFileHandler($logPath, Logger::INFO);
$handler->setFormatter(new LineFormatter(null, null, true, true)); $handler->setFormatter(new LineFormatter(null, null, true, true));
$app->instance('log', new Logger($app->environment(), [$handler])); $app->instance('log', new Logger($app->environment(), [$handler]));