logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maciej Kara? (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LOG4J2-1030) Header in layout created every time application starts
Date Tue, 26 May 2015 14:08:20 GMT
Maciej Kara? created LOG4J2-1030:

             Summary: 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?
            Priority: Critical

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:

protected OutputStreamManager(final OutputStream os, final String streamName, final Layout<?>
layout) {
        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);

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
            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,
        this.isImmediateFlush = immediateFlush;
        this.randomAccessFile = raf;
        this.buffer = ByteBuffer.allocate(bufferSize);

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

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message