Logs spanning several lines end up as separate log events on AWS using quarkus-amazon-lambda
Describe the bug
Using the quarkus-amazon-lambda extension to deploy Quarkus functions leads to log entries containing newlines spanning several log events in CloudWatch logs, as the extension relies on the console output to be picked up by the CloudWatch service and does not send CloudWatch events itself. This is especially annoying for stack traces or formatted JSON output.
String event = """
{
"foo": "bar"
}
""";
log.info("Event:%n{}, event);
Console:
2021-11-10 15:19:08,286 INFO [com.gin.Function] (Lambda Thread (NORMAL)) Event:
{
"foo": "bar"
}
CloudWatch:
2021-11-10 15:19:08,286 INFO [com.gin.Function] (Lambda Thread (NORMAL)) Event:
{
"foo": "bar"
}
Expected behavior
One Cloudwatch Logs log event created per logger call issued in quarkus code.
Actual behavior
One CloudWatch Logs log event created per newline encountered in logger calls issued in Quarkus code.
How to Reproduce?
It can be reproduced by adding the example above to the default code generated by the quarkus-amazon-lambda extension.
Output of uname -a or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.4.1
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
It might suffice to make the built-in jboss logging filtering capabilities available in quarkus, as a workaround may just be to substitute all newlines with carriage returns, i.e quarkus.log.filter."filters".substitute-all=\n, \r (or maybe quarkus.log.console.filter-spec=substituteAll("\n","\r") to align more to actual jboss logging?). This could then be a configuration added by default by the quarkus-amazon-lambda extension.
/cc @matejvasek, @patriot1burke
#10796 seems to be somewhat related (access to/ modification of log records before they are sent to the console).
This really needs to be solved. I'd be okay with the workaround described in the "additional information" section.
I have the same problem. We are using the REST client and log the request-response as defined here.
%prod.quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n
The current logging looks like this:
It seems like the trace-id's are not added to the body because of the newlines in the response. These logs are then excluded from the trace-log-correlation. I would like an option to disable these newlines. I would propose to add a %S format (simple message without newlines).