-
Notifications
You must be signed in to change notification settings - Fork 90
Full stack regression for structured logging #41
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
Conversation
@@ -1,9 +1,9 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<Configuration packages="com.amazonaws.services.lambda.runtime.log4j2"> | |||
<Appenders> | |||
<Console name="JsonAppender" target="SYSTEM_OUT"> | |||
<File name="JsonAppender" fileName="target/logfile.json"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change make log4j to log to a file which we have used in our regression test to make sure the structured logging works correctly with correct lambda keys injected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, it is not the default appender? Why not creating two log4j config file to test both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's so difficult to test system out. I think this is a very slick way of testing the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok good point
initMocks(this); | ||
setupContext(); | ||
//Make sure file is cleaned up before running full stack logging regression | ||
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
assertThat(Files.lines(Paths.get("target/logfile.json"))) | ||
.hasSize(1) | ||
.allSatisfy(line -> assertThat(parseToMap(line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v cool.
Closes #31
This test if the logs printed via log4j config xml is structured as well has correct keys injected from lambda context