From 1cbaafd894d6f587451e19a55019fbb6ec37f70a Mon Sep 17 00:00:00 2001 From: Sebastian Abondano Date: Mon, 22 Oct 2018 10:12:16 -0400 Subject: [PATCH] Adds log rotation Why: * To limit the total size of the logs retained while still allowing analysis of recent events. * Issue link: n/a This change addresses the need by: * Editing the logger backends to do file rotation every 50mb and keep the last 19 log files per logger backend. 50mb * 20 = ~1gb --- apps/block_scout_web/config/prod.exs | 3 ++- apps/ethereum_jsonrpc/config/prod.exs | 3 ++- apps/explorer/config/prod.exs | 3 ++- apps/indexer/config/prod.exs | 6 ++++-- config/prod.exs | 7 +++++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/block_scout_web/config/prod.exs b/apps/block_scout_web/config/prod.exs index f986447be3..a6de66fea4 100644 --- a/apps/block_scout_web/config/prod.exs +++ b/apps/block_scout_web/config/prod.exs @@ -26,4 +26,5 @@ config :block_scout_web, BlockScoutWeb.Endpoint, config :logger, :block_scout_web, level: :info, - path: Path.absname("logs/prod/block_scout_web.log") + path: Path.absname("logs/prod/block_scout_web.log"), + rotate: %{max_bytes: 52_428_800, keep: 19} diff --git a/apps/ethereum_jsonrpc/config/prod.exs b/apps/ethereum_jsonrpc/config/prod.exs index 84d1142f93..0f1324c682 100644 --- a/apps/ethereum_jsonrpc/config/prod.exs +++ b/apps/ethereum_jsonrpc/config/prod.exs @@ -2,4 +2,5 @@ use Mix.Config config :logger, :ethereum_jsonrpc, level: :info, - path: Path.absname("logs/prod/ethereum_jsonrpc.log") + path: Path.absname("logs/prod/ethereum_jsonrpc.log"), + rotate: %{max_bytes: 52_428_800, keep: 19} diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index de2fbca77f..03bb4e460d 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -11,7 +11,8 @@ config :explorer, Explorer.Repo, config :logger, :explorer, level: :info, - path: Path.absname("logs/prod/explorer.log") + path: Path.absname("logs/prod/explorer.log"), + rotate: %{max_bytes: 52_428_800, keep: 19} variant = if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do diff --git a/apps/indexer/config/prod.exs b/apps/indexer/config/prod.exs index 375eed8814..f342efa867 100644 --- a/apps/indexer/config/prod.exs +++ b/apps/indexer/config/prod.exs @@ -2,12 +2,14 @@ use Mix.Config config :logger, :indexer, level: :info, - path: Path.absname("logs/prod/indexer.log") + path: Path.absname("logs/prod/indexer.log"), + rotate: %{max_bytes: 52_428_800, keep: 19} config :logger, :indexer_token_balances, level: :debug, path: Path.absname("logs/prod/indexer/token_balances/error.log"), - metadata_filter: [fetcher: :token_balances] + metadata_filter: [fetcher: :token_balances], + rotate: %{max_bytes: 52_428_800, keep: 19} variant = if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do diff --git a/config/prod.exs b/config/prod.exs index fadd9254f5..5503ebbacf 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -6,6 +6,9 @@ config :logger, :console, level: :info config :logger, :ecto, level: :info, - path: Path.absname("logs/prod/ecto.log") + path: Path.absname("logs/prod/ecto.log"), + rotate: %{max_bytes: 52_428_800, keep: 19} -config :logger, :error, path: Path.absname("logs/prod/error.log") +config :logger, :error, + path: Path.absname("logs/prod/error.log"), + rotate: %{max_bytes: 52_428_800, keep: 19}