diff --git a/lib/fluent/command/fluentd.rb b/lib/fluent/command/fluentd.rb index 93e2c35cfe..debef108dd 100644 --- a/lib/fluent/command/fluentd.rb +++ b/lib/fluent/command/fluentd.rb @@ -311,6 +311,16 @@ require 'fluent/supervisor' if opts[:supervise] + if Fluent.windows? + if opts[:log_path] && opts[:log_path] != "-" + if opts[:log_rotate_age] || opts[:log_rotate_size] + require 'pathname' + + log_path = Pathname(opts[:log_path]).sub_ext("-supervisor#{Pathname(opts[:log_path]).extname}").to_s + opts[:log_path] = log_path + end + end + end Fluent::Supervisor.new(opts).run_supervisor else if opts[:standalone_worker] && opts[:workers] && opts[:workers] > 1 diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 44715b55f7..35f443f0ac 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -354,13 +354,21 @@ def initialize(path, level, chuser, chgroup, opts, log_rotate_age: nil, log_rota @log_rotate_size = log_rotate_size end + def worker_id_suffixed_path(worker_id, path) + require 'pathname' + + Pathname(path).sub_ext("-#{worker_id}#{Pathname(path).extname}").to_s + end + def init(process_type, worker_id) @opts[:process_type] = process_type @opts[:worker_id] = worker_id if @path && @path != "-" @logdev = if @log_rotate_age || @log_rotate_size - Fluent::LogDeviceIO.new(@path, shift_age: @log_rotate_age, shift_size: @log_rotate_size) + Fluent::LogDeviceIO.new(Fluent.windows? ? + worker_id_suffixed_path(worker_id, @path) : @path, + shift_age: @log_rotate_age, shift_size: @log_rotate_size) else File.open(@path, "a") end