Dynatrace OpenKit logging
There are two different ways to log with OpenKit:
Configure OpenKit to use the built-in console logger
Configure OpenKit to use a custom logger implementation
Logging via console logger
OpenKit includes a console logger. By default, any error or warning message is logged to stdout
. When you set a log level, all log events with the same or higher prior levels are logged.
OpenKit uses the following log levels:
Log level | Priority | Description |
---|---|---|
Debug | 0 | For debugging and development. Not recommended for production due to a high volume of log entries. |
Info | 10 | General OpenKit flow. |
Warning | 20 | Warnings encountered in OpenKit library, including API usage problems. |
Error | 30 | Errors that cannot be handled by OpenKit. |
1OpenKit openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)2 .withLogLevel(LogLevel.DEBUG) // enable Debug, Info, Warning, and Error log events3 .build();
Logging via custom logger
You can also configure OpenKit with a custom logger implementation. Implement a custom logger to log OpenKit messages using the logging framework of your choice.
1import com.dynatrace.openkit.api.Logger;23class MyCustomLoggerImpl implements Logger {4 // implement interface methods5}67Logger customLogger = new MyCustomLoggerImpl();89OpenKit openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)10 .withLogger(customLogger)11 .build();