FileAppender creates empty log files before any message is written

Open Beginner friendly
#745 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
devtools

Research direction

Start at the FileAppender initialization and write() entry point described in the issue, then trace how FileOutputStream is currently opened. Verify append mode preserves existing contents, non-append mode truncates as before, and that an appender which receives no message creates neither a file nor its parent directory.

Written by the indexing model from the issue text.

Description

Description

FileAppender currently opens its FileOutputStream during initialization. This creates the log file, and potentially its parent directory, even when no log message is ever written.

The file should be created only when the first message is logged. Existing behavior should otherwise be preserved:

  • Append mode keeps existing contents.
  • Non-append mode truncates an existing file so logging starts fresh.
  • If no message is written, no new empty log file should be created.

The proposed fix is to open FileOutputStream lazily from write() instead of opening it during appender configuration.

Dominant language
C++
Stars
302
Forks
142
Avg merge
1d 22h
Merged PRs (30d)
27

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/logging-log4cxx

All issues in apache/logging-log4cxx

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.