From 29161e1c68253e4ba4cd59a4b648482e70e24ae9 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 1 Sep 2016 11:45:20 -0400 Subject: [PATCH] Add max_request_log_params_size config (was hardcoded to 1000). No issue # --- services/api/config/application.default.yml | 6 ++++++ services/api/config/initializers/lograge.rb | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml index ed3b517757..99d2a10427 100644 --- a/services/api/config/application.default.yml +++ b/services/api/config/application.default.yml @@ -183,6 +183,12 @@ common: # Default lifetime for ephemeral collections: 2 weeks. default_trash_lifetime: 1209600 + # Maximum characters of (JSON-encoded) query parameters to include + # in each request log entry. When params exceed this size, they will + # be JSON-encoded, truncated to this size, and logged as + # params_truncated. + max_request_log_params_size: 2000 + # Maximum size (in bytes) allowed for a single API request. This # limit is published in the discovery document for use by clients. # Note: You must separately configure the upstream web server or diff --git a/services/api/config/initializers/lograge.rb b/services/api/config/initializers/lograge.rb index e5bd2002fa..4b1aea9e70 100644 --- a/services/api/config/initializers/lograge.rb +++ b/services/api/config/initializers/lograge.rb @@ -5,8 +5,8 @@ Server::Application.configure do exceptions = %w(controller action format id) params = event.payload[:params].except(*exceptions) params_s = Oj.dump(params) - if params_s.length > 1000 - { params_truncated: params_s[0..1000] + "[...]" } + if params_s.length > Rails.configuration.max_request_log_params_size + { params_truncated: params_s[0..Rails.configuration.max_request_log_params_size] + "[...]" } else { params: params } end -- 2.30.2