You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds some debug logging in various
components and adds a custom interceptor that performs
http message logging while redacting secrets in the debug messages.
Signed-off-by: Phil Adams <phil_adams@us.ibm.com>
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,48 @@ The java-sdk-core project supports the following types of authentication:
47
47
48
48
For more information about the various authentication types and how to use them with your services, click [here](Authentication.md).
49
49
50
+
## Logging
51
+
This project uses the [java.util.logging](https://docs.oracle.com/en/java/javase/11/core/java-logging-overview.html)
52
+
framework for logging errors, warnings, informational and debug messages. The output is controlled by configuring the desired
53
+
logging level (SEVERE, WARNING, INFO, FINE, etc.) for various loggers.
54
+
55
+
Each class within the project creates its own logger which is named after the class (e.g. `com.ibm.cloud.sdk.core.service.BaseService`).
56
+
The logger names form a hierarchy that mirrors the package/class hierarchy. A logging level can be configured for an individual logger
57
+
or for a group of loggers by leveraging the package name hierarchy.
58
+
59
+
You can configure the logging framework programmatically by using the [java.util.logging API](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html) to create and configure
60
+
loggers, handlers and formatters. Please consult the logging framework documentation for more details on this.
61
+
62
+
You can also configure the framework by defining the desired configuration in a file, then
63
+
supplying the name of the file to the logging framework when you run your application.
64
+
Included with this project are two files which serve as examples of how to configure the logging framework:
65
+
*`logging.properties`: this file contains the default configuration which will display messages that are logged at
66
+
level INFO and above (e.g. INFO, WARNING, SEVERE) on the console
67
+
*`debug-logging.properties`: this file contains a sample configuration that will set the logging level to FINE for all
68
+
Java SDK core loggers and INFO for all other loggers
69
+
70
+
To cause the logging framework to use a particular configuration file when running your java application, specify the
71
+
name of the configuration file with the `java.util.logging.config.file` system property, like this:
For more details regarding the `java.util.logging` API and configuration, please consult the appropriate
77
+
`java.util.logging` documentation.
78
+
79
+
### HTTP message logging
80
+
One particular logging-related subject worth mentioning is the logging of HTTP request and response
81
+
messages as they flow back and forth between the client and server.
82
+
This can be very useful in diagnosing problems or simply verifying that the application is working as intended
83
+
(we all know that sometimes "working as intended" is not necessarily aligned with "working as implemented" :) ).
84
+
85
+
The easiest way to enable HTTP message logging in the Java SDK core library is to simply configure
86
+
logging level FINE (or FINER or FINEST) for the `com.ibm.cloud.sdk.core.service.BaseService` logger.
87
+
This has the side-effect of causing an interceptor to be registered with the underlying `okhttp3` HTTP transport layer which performs
88
+
logging of HTTP request and response messages. Note that the `debug-logging.properties` file contains a configuration that will
89
+
include HTTP message logging.
90
+
91
+
50
92
## Issues
51
93
52
94
If you encounter an issue with this project, you are welcome to submit a [bug report](https://github.com/IBM/java-sdk-core/issues).
0 commit comments