Skip to content

Commit

Permalink
Merge pull request fluent#4188 from daipom/fix-logger-setup-failure
Browse files Browse the repository at this point in the history
Fix failure to launch Fluentd on Windows with log rotation but not specifying the log path in the command line
  • Loading branch information
ashie authored May 30, 2023
2 parents dc7e4b2 + 0e540fe commit dcc05e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def setup_global_logger(supervisor: false)
actual_log_path = @log_path

# We need to prepare a unique path for each worker since Windows locks files.
if Fluent.windows? && rotate
if Fluent.windows? && rotate && @log_path && @log_path != "-"
actual_log_path = Fluent::Log.per_process_path(@log_path, process_type, worker_id)
end

Expand Down
13 changes: 13 additions & 0 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,19 @@ def test_logger_with_rotate_age_and_rotate_size(rotate_age)
assert_equal 10, $log.out.instance_variable_get(:@shift_size)
end

def test_can_start_with_rotate_but_no_log_path
config_path = "#{@tmp_dir}/empty.conf"
write_config config_path, ""

sv = Fluent::Supervisor.new(
config_path: config_path,
log_rotate_age: 5,
)
sv.__send__(:setup_global_logger)

assert_true $log.stdout?
end

sub_test_case "system log rotation" do
def parse_text(text)
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
Expand Down

0 comments on commit dcc05e5

Please sign in to comment.