Logging for OpenKit

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

Log using the console logger

OpenKit includes a console logger. By default any error or warning message is logged to stdout. By enabling the verbose mode, all log messages (debug, info, warnings, and errors) are logged.

OpenKit openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)
    .enableVerbose()  //
    .build();

Log using a custom logger

OpenKit can also be configured with a custom logger implementation. Implement a custom logger to log OpenKit messages using the logging framework of your choice.

import com.dynatrace.openkit.api.Logger;

class MyLoggerImpl implements Logger {
  // implement interface methods
}

Logger logger = new MyLoggerImpl();

OpenKit openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)
    .withLogger(customLogger)
    .build();