Skip to content

Commit

Permalink
Merge pull request #2583 from tsg/backport_2571
Browse files Browse the repository at this point in the history
Backport: Fix panic if logging directory cannot be generated (#2571)
  • Loading branch information
monicasarbu authored Sep 19, 2016
2 parents 89cfb2e + 57101de commit 786d9c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha5...master[Check the HEAD d
- Fix array value support in -E CLI flag. {pull}2521[2521]
- Fix merging array values if -c CLI flag is used multiple times. {pull}2521[2521]
- Fix beats failing to start due to invalid duplicate key error in configuration file. {pull}2521[2521]
- Fix panic on non writable logging directory.

*Metricbeat*
- Fix module filters to work properly with drop_event filter. {issue}2249[2249]
Expand Down
11 changes: 7 additions & 4 deletions libbeat/logp/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ func SetToSyslog(toSyslog bool, prefix string) {
}

func SetToFile(toFile bool, rotator *FileRotator) error {
_log.toFile = toFile
if _log.toFile {
_log.rotator = rotator

if toFile {
err := rotator.CreateDirectory()
if err != nil {
return err
Expand All @@ -174,6 +171,12 @@ func SetToFile(toFile bool, rotator *FileRotator) error {
if err != nil {
return err
}

// Only assign rotator on no errors
_log.rotator = rotator
}

_log.toFile = toFile

return nil
}

0 comments on commit 786d9c9

Please sign in to comment.