You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2015/10/04 23:40:26 UTC

[jira] [Closed] (LOG4J2-1030) Header in layout created every time application starts

     [ https://issues.apache.org/jira/browse/LOG4J2-1030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma closed LOG4J2-1030.
-------------------------------

> 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
>             Fix For: 2.4
>
>
> 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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org