ramanathan1504 commented on issue #3697:
URL: 
https://github.com/apache/logging-log4j2/issues/3697#issuecomment-4131994712

   @ppkarwasz
   
   Currently, the size check happens after the event is written. To guarantee 
strict size limits, we’d need to:
   - Estimate the size of the event before writing it.
   - If writing the event would exceed the limit, roll over first.
   - Then write the event to the new file.
   
   This would ensure no rolled file ever exceeds the configured size. However, 
it’s a significant change and would need to be opt-in for backward 
compatibility.
   
   The main change would be in the file appender logic (likely in 
`RollingFileManager`). Before writing each event, the code would need to:
   - Format the event to estimate its size.
   - Check if (current file size + event size) > maxFileSize.
   - If so, roll over before writing.
   
   This logic can’t be implemented in `SizeBasedTriggeringPolicy` alone, since 
it doesn’t know the event size before writing. The new behavior should be 
configurable.
   
   I'm planning to implement this strict pre-event rollover as described above, 
making it opt-in and ensuring backward compatibility. If anyone has 
suggestions, concerns, or best practices to share.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to