diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 10865c1ab4..51e4563860 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -315,6 +315,7 @@ def self.load_config(path, params = {}) ) # this #init sets initialized logger to $log logger_initializer.init(:supervisor, 0) + logger_initializer.apply_options(format: params['log_format'], time_format: params['log_time_format']) logger = $log command_sender = Fluent.windows? ? "pipe" : "signal" @@ -691,6 +692,8 @@ def supervise 'rpc_endpoint' => @system_config.rpc_endpoint, 'enable_get_dump' => @system_config.enable_get_dump, 'counter_server' => @system_config.counter_server, + 'log_format' => @system_config.log.format, + 'log_time_format' => @system_config.log.time_format, } se = ServerEngine.create(ServerModule, WorkerModule){ diff --git a/test/test_supervisor.rb b/test/test_supervisor.rb index f4b3fd39b9..6779a0057c 100644 --- a/test/test_supervisor.rb +++ b/test/test_supervisor.rb @@ -235,6 +235,33 @@ def test_load_config Timecop.return end + def test_load_config_for_logger + tmp_dir = "#{TMP_DIR}/dir/test_load_config_log.conf" + conf_info_str = %[ + + + format json + time_format %FT%T.%L%z + + +] + write_config tmp_dir, conf_info_str + params = { + 'use_v1_config' => true, + 'conf_encoding' => 'utf8', + 'log_level' => Fluent::Log::LEVEL_INFO, + 'log_path' => 'test/tmp/supervisor/log', + + 'workers' => 1, + 'log_format' => :json, + 'log_time_format' => '%FT%T.%L%z', + } + + r = Fluent::Supervisor.load_config(tmp_dir, params) + assert_equal :json, r[:logger].format + assert_equal '%FT%T.%L%z', r[:logger].time_format + end + def test_load_config_for_daemonize tmp_dir = "#{TMP_DIR}/dir/test_load_config.conf" conf_info_str = %[