SelectiveLogConsumer - a way to reduce noise while still capturing important information #9253
beargiles
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Server logs are phenomal resources. In many cases your client might get a generic response that provides you little to no hints at what the actual problem is. Meanwhile, the server log spells it out - syntax error, lacking a specific permission, etc.
The default options seem to be "log everything" and "log nothing".
In my experience a reasonable compromise is to identify the difference in our needs between when the server is starting (often very verbose) and once it's fully up (often concise and limited to why specific client calls failed). Not all servers follow this pattern, of course, but this has been a good launching point.
A secondary issue is that many servers produce similar logs as the TestContainer. This is noisy and can cause confusion since the normal filtering, e.g., by log level, doesn't always work as expected.
The code below attempts to extract the logging level of the message and use it instead of the generic
INFO
andWARNING
. This will let us filter by severity.I've had some luck explicitly removing any timestamp, etc., from the logged message. It definitely reduces the visual clutter. I haven't included it below since I'm currently investigating what we see with different
--log-driver
values.The best way to handle the switch appears to be extending
waitForContainerStarted()
:We still want to support both
ALL
andNONE
since we'll often want the former option when we're first setting up the container (it tells us the actual configuration) and may want to use the latter in CI/CD in order to reduce log size since our tests should never fail by this point.Beta Was this translation helpful? Give feedback.
All reactions