diff --git a/.env.docker b/.env.docker index 4fae4718c9..c176b40fce 100644 --- a/.env.docker +++ b/.env.docker @@ -17,6 +17,9 @@ APP_KEY=${FF_APP_KEY} APP_URL=${APP_URL} TRUSTED_PROXIES=${TRUSTED_PROXIES} +# The log channel defines where your log entries go to. +LOG_CHANNEL=${LOG_CHANNEL} + # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. DB_CONNECTION=mysql diff --git a/.env.example b/.env.example index aa23f9660a..1ce079c0ab 100644 --- a/.env.example +++ b/.env.example @@ -21,6 +21,9 @@ TZ=UTC APP_URL=http://localhost TRUSTED_PROXIES= +# The log channel defines where your log entries go to. +LOG_CHANNEL=daily + # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. DB_CONNECTION=mysql diff --git a/.env.heroku b/.env.heroku index 9b16f9ab93..b1d6a763f5 100644 --- a/.env.heroku +++ b/.env.heroku @@ -21,6 +21,9 @@ TZ=UTC APP_URL=http://localhost TRUSTED_PROXIES= +# The log channel defines where your log entries go to. +LOG_CHANNEL=syslog + # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. DB_CONNECTION=pgsql diff --git a/.env.sandstorm b/.env.sandstorm index 42c3108dac..811c71e343 100755 --- a/.env.sandstorm +++ b/.env.sandstorm @@ -21,6 +21,9 @@ TZ=UTC APP_URL=http://localhost TRUSTED_PROXIES= +# The log channel defines where your log entries go to. +LOG_CHANNEL=syslog + # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. DB_CONNECTION=mysql diff --git a/.env.testing b/.env.testing index 1b9f7ab7f2..2e91b05f20 100644 --- a/.env.testing +++ b/.env.testing @@ -28,6 +28,9 @@ REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 +# The log channel defines where your log entries go to. +LOG_CHANNEL=dailytest + MAIL_DRIVER=log MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 diff --git a/bootstrap/app.php b/bootstrap/app.php index 67b0a03ed3..8848f99d89 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -70,38 +70,6 @@ $app->singleton( FireflyIII\Exceptions\Handler::class ); -///* Overrule logging if not Sandstorm */ -//if (!(env('IS_SANDSTORM') === true)) { -// $app->configureMonologUsing( -// function (Logger $monolog) use ($app) { -// -// $interface = php_sapi_name(); -// $path = $app->storagePath() . '/logs/ff3-' . $interface . '.log'; -// $level = 'debug'; -// if ($app->bound('config')) { -// $level = $app->make('config')->get('app.log_level', 'debug'); -// } -// $levels = [ -// 'debug' => Logger::DEBUG, -// 'info' => Logger::INFO, -// 'notice' => Logger::NOTICE, -// 'warning' => Logger::WARNING, -// 'error' => Logger::ERROR, -// 'critical' => Logger::CRITICAL, -// 'alert' => Logger::ALERT, -// 'emergency' => Logger::EMERGENCY, -// ]; -// -// $useLevel = $levels[$level]; -// -// $formatter = new LineFormatter(null, null, true, true); -// $handler = new RotatingFileHandler($path, 5, $useLevel); -// $handler->setFormatter($formatter); -// $monolog->pushHandler($handler); -// } -// ); -//} - /* |-------------------------------------------------------------------------- | Return The Application diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000000..f8b2736cea --- /dev/null +++ b/config/logging.php @@ -0,0 +1,97 @@ +. + */ + +declare(strict_types=1); + +return [ + + /* + |-------------------------------------------------------------------------- + | Default Log Channel + |-------------------------------------------------------------------------- + | + | This option defines the default log channel that gets used when writing + | messages to the logs. The name specified in this option should match + | one of the channels defined in the "channels" configuration array. + | + */ + + 'default' => env('LOG_CHANNEL', 'daily'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/ff3-' . php_sapi_name() . '-.log'), + 'level' => env('APP_LOG_LEVEL', 'info'), + 'days' => 7, + ], + 'dailytest' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/test-ff3-' . php_sapi_name() . '-.log'), + 'level' => env('APP_LOG_LEVEL', 'info'), + 'days' => 7, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => 'critical', + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('APP_LOG_LEVEL', 'info'), + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('APP_LOG_LEVEL', 'info'), + ], + ], + +]; \ No newline at end of file