Logo

Get Started

[TUTORIAL] LicenseSpring SDK logging image

[TUTORIAL] LicenseSpring SDK logging

10 MINUTES
Tutorials

Logging allows software developers to see the list of actions that underwent during the execution of their application. This tutorial tackles how to enable logging, when to use logging, the information logged, and how to retrieve the produced logs.

  • How to Turn On Logging

  • When to Use Logging 

  • Information Kept within the Logs

  • How to Retrieve Logs

How to Turn On Logging

By default, logging is disabled. Logging can be enabled, before the product/license is configured within the application.

std::string appName = "NAME"; //input name of application
std::string appVersion = "VERSION"; //input version of application


ExtendedOptions options;
//Setting the parameter to true enables logging, false disables. If we didn't add this line, it would be 
//disabled by default.
options.enableLogging( true ); 

auto configuration = Configuration::Create(
     EncryptStr( "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ), // your LicenseSpring API key (UUID)
     EncryptStr( "XXXXXXXXX-XXXXX-XXXXXXXXXXXXX_XXXXXX_XXXXXX" ), // your LicenseSpring Shared key
     EncryptStr( "XXXXXX" ), // product code that you specified in LicenseSpring for your application
     appName, appVersion, options );

auto licenseManager = LicenseManager::create( pConfiguration );
var options = new LicenseSpring.ExtendedOptions();
//Setting EnableLogging to true enables logging, false disables. If we didn't add this line, it would be 
//disabled by default.
options.EnableLogging = true;
var configuration = new LicenseSpring.Configuration(
            apiKey: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // your LicenseSpring API key (UUID)
            sharedKey: "XXXXXXXXX-XXXXX-XXXXXXXXXXXXX_XXXXXX_XXXXXX", // your LicenseSpring Shared key
            productCode: "XXXXXX", // product code that you specified in LicenseSpring for your application
            appName: "NAME",
            appVersion: "VERSION",
            extendedOptions: options );
var licenseManager = LicenseManager.GetInstance();
licenseManager.Initialize( configuration );
LicenseSpringConfiguration configuration = LicenseSpringConfiguration.builder()
                .apiKey( "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" )
                .productCode( "XXXXXX" )
                .sharedKey( "XXXXXXXXX-XXXXX-XXXXXXXXXXXXX_XXXXXX_XXXXXX" )
                .appName( "NAME" )
                .appVersion( "VERSION" )
                .requestLogging( Logger.Level.FULL ) //Enables logging, would've been disabled without this line
                .build();

LicenseManager licenseManager = LicenseManager.getInstance();
licenseManager.initialize( configuration );

You can also check whether logging is enabled within your application.

configuration->isLoggingEnabled();
bool logging = configuration.IsLoggingEnabled;
configuration.getRequestLogging();

When to Use Logging

Logging is a helpful tool for software developers to reflect on the functionality of their applications. It also assists developers with capturing and fixing unexpected bugs that otherwise would have gone unnoticed. Beyond testing and debugging, logging can be an efficient way to learn the inner workings of the SDK.

Information Kept within the Logs

Any request/response sent/received from the LicenseSpring servers. This includes, but is not limited to:

  • Online activation

  • Online deactivation (where local storage is not cleared)

  • Online checks

  • Getting product information

  • Retrieving/adding device variables from/to the server

  • Syncing consumptions and other features.

Basic hardware information such as:

  • CPU

  • Disk

  • Motherboard

  • Hardware ID

Beyond that, logging will also capture:

  • Local checks

  • Anytime an exception occurs, even when caught.

All these will show up in the logs, as well as on what thread, and at the exact date and time they occurred.

How to Retrieve Logs

Log files are kept in the same location as all other LicenseSpring data, such as your local license file. You can find out where this location is on your device, from your application using:

std::wstring path = licenseManager->licenseFilePath();
var path = licenseManager.DataLocation;
String path = configuration.getLicenseFilePath();

Or you can set the location of where you want the logs file as well as all other LicenseSpring data to be stored on your device with:

licenseManager->setDataLocation(L"new/path/to/LicenseSpring/data");
licenseManager.DataLocation = "new/path/to/LicenseSpring/data";
//Java as of August 11th, 2022 does not have a way to set LicenseSpring path

Conclusion

You should now be able to enable/disable logging within your application, know what is on your LicenseSpring logs, and find the location of the logs on your device. These will be very useful when debugging and trying to find errors within your code, however, they should be turned off in your release build, so that end-users do not have access to the logs.

Frequently Asked Questions

Published on: January 16, 2025
Last updated: January 16, 2025

Author

William Gong
Technical Implementation Engineer - LicenseSpring Software

Share

Related Blog Posts
Security Considerations and Crypto Provider image

10 Minutes

Tutorials

Security Considerations and Crypto Provider

Read More

Implement Trial Licenses for your Application [TUTORIAL] image

40 Minutes

Tutorials

Implement Trial Licenses for your Application [TUTORIAL]

Read More