logging-log4j2
logging-log4j2 copied to clipboard
LOG4J2-3280 - Add support for microsecond precision in RFC5424Layout
This pull request is to imlement RFE LOG4J2-3280 The change
- Adds new attribute timestampPrecision to Rfc5424Layout and SyslogAppender.
- Replaces existing logic to append timestamp and uses two new fixed date formats to format timestamp.
- Added new unit tests
- Verified that 'mvn clean install' and 'mvn verify' are successful.
I believe the failure in PropertiesConfigurationTest is unrelated to this change, and being fixed with #685 Once that is fixed, how do I get this PR to build and run CI tests again?
Hi @atulpendse You will need to rebase this PR to pick up the latest changes.
Hi @atulpendse You will need to rebase this PR to pick up the latest changes.
Thanks for the info. I have updated PR with the latest from upstream. Latest commit seems to have passed all the tests.
Fantastic work @atulpendse! Thanks so much!
Mind adding SyslogAppender tests ~~and a changes.xml entry~~, please?
I am also not sure if a timestampPrecision argument of type String is the right way to go. Thinking out loudly:
- Why don't we simply make the instant formatting pattern configurable?
- Doesn't the spec enforce a certain precision?
- If not, why don't we simply (automatically?) pick the most precise representation possible?
I would NOT update changes.xml, this makes cherry-picking the commit to master impossible.
IMHO, cherry-picking to master is almost already impossible. Nevertheless, I will rephrase my comment to exclude the changes.xml part.
@vy Thanks for taking time to review the PR. Here are my thoughts about questions you raised.
I am also not sure if a
timestampPrecisionargument of typeStringis the right way to go. Thinking out loudly:
- Why don't we simply make the instant formatting pattern configurable?
With making pattern configurable, there is risk of the message not being compliant to RFC5424 spec (if someone updates format that is not as per RFC5424)
- Doesn't the spec enforce a certain precision?
The spec does not enforce 'a particular' precision, rather it supports three precisions
- Without any sub-second value
- Milliseconds
- Microseconds
- If not, why don't we simply (automatically?) pick the most precise representation possible?
We could, that would work for my usecase. But if someone is expecting precision to be millisecond (like my app was expecting it to be microsecond), it would break their app.
I will add a test for SyslogAppender.
Commit fbccefc updates existing test for SyslogAppender
@vy @garydgregory anything else that I should do to make progress on this PR?
I only took a cursory look this AM. Please use the style of the files you are editing: Use spaces, no tabs. The bigger question is whether we should use an enum for the microsecond vs millisecond format, @jvz any thoughts?
Thanks for taking time to review. I have fixed the concerns with latest commit. Now timestampPrecision is an enum.
Looks like a test is failing on MacOS. Failure doesn't look related to my changes though. I don't have access to Mac to find out why exactly it's failing.
@garydgregory, please let me know how I can help to get the PR going. I rebased the PR with latest code and submitted back with commit b425497
Just FYI.. I was able to build it successfully on my Mac. Last time @garydgregory tried to submit build with this PR, it failed on Mac, not sure why.
Hello @atulpendse In general, you want to avoid breaking binary compatibility, so that means not editing public and protected type names and method signatures. This is critical in the log4j-api module and less so in others, but, in this case it seems easy to do. Also, we have been switching from factory methods to builders as we go from release to release in order to avoid keeping on deprecating factory methods. So edit or add builders, don't edit factory methods is the idea. TY!
@vy Why was this closed? To be honest, I am not sure why this hasn't been merged.
It's a side effect of deleting the release-2.x branch: Github deletes the related PRs.
@atulpendse: can submit again against the 2.x branch?