fix(cloud-logging): removing Logstash dependencies, using Cloud Logging Logback#10274
Conversation
…pender while updating dependencies and test configuration
There was a problem hiding this comment.
Code Review
This pull request updates the manual logging implementation in the Cloud Run Java sample to use Google Cloud Logging Logback integration instead of Logstash. Specifically, it replaces logstash-logback-encoder with google-cloud-logging-logback, migrates structured logging from StructuredArguments.kv to SLF4J's Mapped Diagnostic Context (MDC), and updates the logback.xml configuration to use LoggingAppender redirecting to stdout. Additionally, test setup has been refactored to handle output streams statically, and the test assertions were updated to match the new INFO log level. I have no feedback to provide as the changes are clean and correct.
…t neccesary for cloud test
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates the manual logging implementation from using Logstash Logback encoder to the Google Cloud Logging Logback appender. It replaces structured logging via key-value pairs with SLF4J's Mapped Diagnostic Context (MDC) and updates the test assertions accordingly. A review comment suggests restoring the original System.out stream in @AfterClass to prevent console output pollution for other tests.
…effects on other tests
| logger.error( | ||
| "This is the default display field.", | ||
| kv("component", "arbitrary-property"), | ||
| kv("severity", "NOTICE"), |
There was a problem hiding this comment.
Important to mention that the severity on SLF4J logger object is given by the logged method (e.g., logger.info() maps to INFO, logger.warn() to WARNING, logger.error() to ERROR).
Description
Fixes b/362827197
Updates the Google Cloud Run manual logging sample for Java to use the officially recommended Google Cloud Logging Logback Appender (
google-cloud-logging-logback) instead of the third-partylogstash-logback-encoderplugin.Main changes:
logstash-logback-encoderplugin alongside custom Logstashkv()key-value parameters used to write JSON structured logs.google-cloud-logging-logbackplugin, which natively supports structured logging and can output directly to standard output via<redirectToStdout>true</redirectToStdout>.libraries-bomunder<dependencyManagement>to manage Google Cloud library versions.logstash-logback-encoderwithgoogle-cloud-logging-logback.logback-classicandlogback-corealigned at version1.4.14to ensure seamless SLF4J 2.x provider binding.LoggingAppender, configured with<redirectToStdout>true</redirectToStdout>.@BeforeClassbeforespark-javaloads the class-level static logger."INFO"instead of"NOTICE".Checklist
pom.xmlparent set to latestshared-configurationmvn clean verifyrequiredmvn -P lint checkstyle:checkrequiredmvn -P lint clean compile pmd:cpd-check spotbugs:checkadvisory only