SDKs
...
Tutorials
Best Practices

Logging

9min

Logging is a fundamental aspect of software development and system administration, providing a valuable means to record and monitor the activities and events within an application or system.

This tutorial aims to equip you with the knowledge and skills to enable logging in your applications or systems effectively.

We will explore the essential concepts of logging, such as log levels, log formats, and log destinations.

By the end of this tutorial, you will have a clear understanding of how to incorporate logging into your projects and locate log files for analysis and debugging purposes.

Prerequisites

  1. Completed the Getting Started Tutorial, specifically:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Implemented basic license management, including license activations, deactivations, and both online and local license checks.

Enabling Logging and Verifying Its Status

Logging is enabled within the Configuration object, prior to the product and license being configured within the application.

Note: Logging is disabled by default.

Logging can be enabled using the following method:

C++
C#
Java
Swift
Python


Warning: Logging is for developer use only, ensure it is disabled in your release builds.

To see how to enable logging in an application environment, see below:

C++
C#
Java
Python


Developers can chack for whether logging is enabled in the current Configuration through using:

C++
C#
Java


Location of the Log File

The location of log files is a critical aspect of logging configuration, determining where logged data is stored and accessed for monitoring, debugging, and analysis purposes.

Default Location in Different Environments

The location of the log file depends on the operating system in use.

On Windows, the default SDK data location is: {SystemDrive}:/Users/{UserName}/AppData/Local/LicenseSpring/{ProductCode}

On Linux, the default SDK data location is: HOME/.LicenseSpring/LicenseSpring/{ProductCode}

On macOS, the default SDK data location is: ~/Library/Application Support/LicenseSpring/{ProductCode}

These default paths indicate where the log file and other SDK-related data are stored based on the specific operating system.

Getting Current Data Location

Log files are stored in the same location as all other LicenseSpring data, including your local license file.

To discover the specific location of this data on your device, you can utilize the corresponding functionality provided within your application.

C++
C#
Java
Python


Changing Data Location

Changing the data location involves modifying the application's configuration or settings to redirect where data, including log files, is stored.

Developers and administrators may implement this change to consolidate data in a centralized location, move data to faster storage media, or ensure data privacy and compliance with regulations.

C++
C#
Java
Python


Warning: If there's a license in the new location, it will be set as current license, otherwise the current license will be removed from memory.