How to Use Logging

Published on: August 11, 2022
hero
Table of Contents:

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.

cpp
csharp
java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 );

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

cpp
csharp
java
1 configuration->isLoggingEnabled();

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:

cpp
csharp
java
1 std::wstring path = licenseManager->licenseFilePath();

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:

cpp
csharp
java
1 licenseManager->setDataLocation(L"new/path/to/LicenseSpring/data");

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.

FAQ

Q: My logs keep getting deleted after I deactivate my license.

Deactivating on most SDKs will delete all LicenseSpring related data. Luckily, most SDKs also offer a way to deactivate a license without deleting the license. To see more information on deactivation, see our Getting Started Tutorial.

Q: Where are my logs by default?

It depends on your OS and what language you are using, but generally:

Default SDK data location on Windows is: {SystemDrive}:/Users/{UserName}/AppData/Local/LicenseSpring/{ProductCode}

Default SDK data location on Linux is: HOME/.LicenseSpring/LicenseSpring/{ProductCode}

Default SDK data location on MAC is: ~/Library/Application Support/LicenseSpring/{ProductCode}