shadabahmed / logstasher

Awesome rails logs
MIT License
821 stars 136 forks source link

Configuring rotation of logstasher log file #136

Closed julitrows closed 7 years ago

julitrows commented 7 years ago

Hello,

I've got logstasher configured on an application that rotates log files differently depending on the env:

# Environment A
config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 2, 1.megabytes)

This produces two files: environment_a.log and environment_a.log.0, that get ditched as they reach 1mb ( .log becomes log.0 and the former .log.0 is removed, and a new .log is created)

And then:

# Environment B
config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 'daily')

This produces: environment_b.log (current file), and when the day changes, that file gets the date appended (environment_b.log.20170416), and the daily files are kept.

So, is there a way I can configure logstasher to produce the logstasher_environment_x.log files in the same fashion?

Thanks

julitrows commented 7 years ago

Ok, turns out that simply doing:

config.logstasher.logger = Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log"), 'daily')

or

config.logstasher.logger = Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log"), 2, 1.megabytes)

...should be enough. Should have tried that from the start, but didn't see in the doc a clear hint at it.