[
https://issues.apache.org/jira/browse/LOG4J2-1030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14615749#comment-14615749
]
Remko Popma commented on LOG4J2-1030:
-------------------------------------
Adding a new attribute will have large repercussions: all layouts would need to
support it, and all OutputStreamAppenders would need to have separate behaviour
for it.
And all that because we speculate there may be people who like the behaviour
caused by this bug. I feel we should just fix it to work according to spec, and
accept new feature requests if some people like the old behaviour.
> Header in layout created every time application starts
> ------------------------------------------------------
>
> Key: LOG4J2-1030
> URL: https://issues.apache.org/jira/browse/LOG4J2-1030
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders, Core, Layouts
> Affects Versions: 2.3
> Reporter: Maciej KaraĆ
> Assignee: Remko Popma
>
> Header is appended to OutputStream every time Appender/Manager constructor is
> called. This causes appending header every time application restarts which I
> think is wrong. Examples:
> {code:java}
> protected OutputStreamManager(final OutputStream os, final String streamName,
> final Layout<?> layout) {
> super(streamName);
> this.os = os;
> this.layout = layout;
> if (layout != null) {
> final byte[] header = layout.getHeader();
> if (header != null) {
> try {
> this.os.write(header, 0, header.length);
> } catch (final IOException ioe) {
> LOGGER.error("Unable to write header", ioe);
> }
> }
> }
> }
> {code}
> {code:java}
> public RollingRandomAccessFileManager(final RandomAccessFile raf, final
> String fileName,
> final String pattern, final OutputStream os, final boolean append,
> final boolean immediateFlush, final int bufferSize, final long
> size, final long time,
> final TriggeringPolicy policy, final RolloverStrategy strategy,
> final String advertiseURI, final Layout<? extends Serializable>
> layout) {
> super(fileName, pattern, os, append, size, time, policy, strategy,
> advertiseURI, layout, bufferSize);
> this.isImmediateFlush = immediateFlush;
> this.randomAccessFile = raf;
> isEndOfBatch.set(Boolean.FALSE);
> this.buffer = ByteBuffer.allocate(bufferSize);
> writeHeader();
> }
> {code}
> I think header should be appended to the file only once. It might be
> configurable if one wants to append header after application restart.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]