Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
JavaEE Guides
Configuring SDL Logging

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(TAG, "info message goes here");

To log a warning message:

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

To log an error message:

DebugTool.logError(TAG, "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(TAG, "error message goes here", new SdlException("Sdl connection failed", SdlExceptionCause.SDL_CONNECTION_FAILED));
View on GitHub.com
Previous Section Next Section