apache / apache/logging-log4j2

RandomAccessFileAppender does not write header to file

Open
#2,020 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

## Description

RandomAccessFileAppender does not write the header configured in the layout to the output file.

## Configuration

**Version:** 2.22.0

**Operating system:** Windows 10

**JDK:** Temurin 11.0.16.1

## Reproduction

Using the following log4j2.xml:
```



%d{DEFAULT} [%-5p] %c{1} - %m%n

*** HEADER ***${sys:line.separator}













```

Combined with a simple program that just logs something, ie:
```
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Test {
private static final Logger LOG = LogManager.getLogger();

public static void main(String[] args) {
LOG.info("Test");
}
}
```

This creates two files. The file.log is as expected:
```
*** HEADER ***
2023-11-30 16:54:04,898 [INFO ] Test - Test
```

But randomaccessfile.log does not contain the header line:
```
2023-11-30 16:54:04,898 [INFO ] Test - Test
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.