Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

Configuring SDL Logging

Sdl Java Suite has a built-in logging framework that is designed to make debugging easier. It provides many of the features common to other 3rd party logging frameworks for java and can be used by your own app as well. We recommend that your app's integration with SDL provide logging using this framework rather than any other 3rd party framework your app may be using or System.out.print. This will consolidate all SDL related logs into a common format and to a common destination.

Enabling the DebugTool

To make sure that log messages are displayed, you should enable the SDL Debug Tool:

DebugTool.enableDebugTool();

If you don't want the messages to be logged, you can disable the Debug Tool anytime:

DebugTool.disableDebugTool();
Note

If you use SDL Debug Tool to log messages without enabling the DebugTool nothing wrong will happen. It will simply not display the log messages. This gives the develop control on whether the logs should be displayed or not.

Logging messages

The SDL debug tool can be used to log messages with different log levels. The log level defines how serious the log message is. This table summarizes when to use each log level:

Log Level When to use
Info Use this to post useful information to the log
Warning Use this when you suspect something shady is going on
Error Use this when bad stuff happens

To log an info message:

DebugTool.logInfo("info message goes here");

To log a warning message:

DebugTool.logWarning("warning message goes here");

To log an error message:

DebugTool.logError("error message goes here");

If you want to log error message with exception, you can add the exception as a second parameter to the logError method:

DebugTool.logError("error message goes here", new SdlException("Sdl connection failed", SdlExceptionCause.SDL_CONNECTION_FAILED));

Filtering logs

The log level defines which logs will be logged to the target outputs. For example, if you set the log level filter in Logcat to Warning, all error, and warning logs will be logged, but info level logs will not be logged.

LogLevel Visible Logs
Error error
Warning error and warning
Info error, warning, and info
View on GitHub.com
Previous Section Next Section