Replace printStackTrace with SLF4J logging to improve observability #8053
+8
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces direct calls to printStackTrace() with proper SLF4J logging in RPCClientProxyHandler.kt and CryptoUtils.kt. Using a logger improves observability by ensuring stack traces are directed to the configured log appenders rather than stdout/stderr, and allows for better log level management.
Changes:
RPCClientProxyHandler.kt: Replaced rpcCallSite?.printStackTrace() with log.warn("Call site stack trace:", rpcCallSite). This ensures that call site stack traces are logged as warnings and preserved in the node logs.
CryptoUtils.kt: Added a companion object with a logger to DummySecureRandomSpi and replaced printStackTrace(System.out) with log.warn(...). This unifies the logging approach within the class.
Motivation:
Usage of printStackTrace() is generally discouraged in production code as it bypasses the logging framework, making it harder to track errors and debug issues continuously. These changes align with the codebase's standard logging practices.
Verification:
Verified that CallSite is a Throwable and will be correctly logged by SLF4J.
Ran net.corda.core.crypto.CryptoUtilsTest to ensure no regressions in crypto utilities.
Verified compilation of the client:rpc module.