Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs Truncated and Subsequent Entries Appended in Log Files #3408

Open
kvssg123 opened this issue Jan 24, 2025 · 3 comments
Open

Logs Truncated and Subsequent Entries Appended in Log Files #3408

kvssg123 opened this issue Jan 24, 2025 · 3 comments
Labels
appenders Affects one or more Appender plugins waiting-for-user More information is needed from the user

Comments

@kvssg123
Copy link

kvssg123 commented Jan 24, 2025

Description

We are encountering an issue where some log entries within our log files are being truncated. These truncated logs are directly followed by the subsequent log entry, leading to a single, combined log line. This situation also raises concerns about the potential for data loss, as log entries may be missing between those that have been merged. We are also using Log Redactor for masking logs.

Configuration

JDK Version: 21
OS: Linux

Rolling File Appender configuration:

<RollingFile name="File" fileName="${logFile}.log" filePattern="${logbackupdirectory}/${podName}_${sys:port}-%i.log.gz"> <PatternLayout> <Pattern>%d{DATE}{GMT+5:30} %5p %t %X{Id} %c{1}:%L - %m%n %xEx</Pattern> </PatternLayout> <Policies> <SizeBasedTriggeringPolicy size="${sys:LOGSIZE:-50} MB" /> </Policies> <DefaultRolloverStrategy max="${sys:MAXLOGS:-300}" /> </RollingFile>

Logs

Expected Behaviour :

2025-01-03 12:34:56 INFO [Module] Operation completed successfully
2025-01-03 12:34:57 ERROR [Module] An error occurred

Actual behaviour :

2025-01-03 12:34:56 INFO [Module] Operation completed successfu2025-01-03 12:34:57 ERROR [Module] An error occurred

@vy
Copy link
Member

vy commented Jan 24, 2025

  1. Which Log4j version?
  2. If you're not using the most recent version (i.e., 2.24.3), do you still observe the problem when you upgrade to 2.24.3?
  3. Do you still observe the problem when you remove the Log Redactor?

@vy vy added waiting-for-user More information is needed from the user appenders Affects one or more Appender plugins and removed waiting-for-maintainer labels Jan 24, 2025
@kvssg123
Copy link
Author

Thank you for your response. We are currently using Log4j version 2.17.2. The issue occurs exclusively in our production clusters running on AWS EKS. We attempted to reproduce the problem in a controlled environment by generating dummy logs in a multi-threaded setup using the same Log4j2 configuration and version but were unable to replicate the behavior.
Since this issue manifests only in production, it has been challenging to investigate without log redaction enabled. Additionally, these logs are exported to our ELK stack for further analysis. Is there an alternative way to debug this issue without directly experimenting in the production environment?

@github-actions github-actions bot added waiting-for-maintainer and removed waiting-for-user More information is needed from the user labels Jan 25, 2025
@ppkarwasz
Copy link
Contributor

@kvssg123,

Is there an alternative way to debug this issue without directly experimenting in the production environment?

Did you exactly replicate your production environment, including the Java system properties and JRE? I would double check if the garbage-free properties are the same in the two environments.

Can you add %t to your pattern layout to find out if the merged messages are from the same or different threads? I am a little bit surprised you don't use JSON Template Layout with an ECS template: it is the ideal choice for EKS.

@vy vy added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appenders Affects one or more Appender plugins waiting-for-user More information is needed from the user
Projects
None yet
Development

No branches or pull requests

3 participants