Skip to content

Header not written for RollingFileAppender since version 1.5.7 #857

@balrok

Description

@balrok

In 85bed93 the encoderInit()-method was moved from setOutputStream() to start(). The RollingFileAppender will not call start() once a new file is rolled. Therefore these new files won't get a header anymore.
We are using logback to create a binary file which requires a header. Due to this change, only the first file gets the header (because start() calls encoderInit()). But every other file created by RollingFileAppender is without the header.

As a hotfix it works to override the setOutputStream-method with:

public void setOutputStream(final OutputStream outputStream) {	super.setOutputStream(outputStream);	if (isStarted()) {	try {	getOutputStream().write(getEncoder().headerBytes());	} catch (final IOException e) {	addWarn("Konnte etem-Header nicht schreiben. " + e.getMessage());	}	} } 

The isStarted()-check is needed to avoid, that the header is written twice in the beginning.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions