diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index d8f90211197..8f4f4c51c78 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,8 @@ https://github.com/elastic/beats/compare/1.0.0...master[Check the HEAD diff] ==== Bugfixes *Affecting all Beats* +- Fix logging issue with file based output where newlines could be misplaced + during concurrent logging {pull}650[650] *Packetbeat* - Fix setting direction to out and use its value to decide when dropping events if ignore_outgoing is enabled {pull}557[557] diff --git a/libbeat/logp/file_rotator.go b/libbeat/logp/file_rotator.go index af8906384b1..8e34fe3d6b5 100644 --- a/libbeat/logp/file_rotator.go +++ b/libbeat/logp/file_rotator.go @@ -66,15 +66,13 @@ func (rotator *FileRotator) WriteLine(line []byte) error { return err } } + + line = append(line, '\n') _, err := rotator.current.Write(line) if err != nil { return err } - _, err = rotator.current.Write([]byte("\n")) - if err != nil { - return err - } - rotator.current_size += uint64(len(line) + 1) + rotator.current_size += uint64(len(line)) return nil }