website logo
⌘K
Getting Started
Introduction
Basic Concepts
Opening an Account
Creating & Configuring Products
Integrating SDK and Configuring License Fulfillment
Activate a Key-Based License
Vendor Platform
Issuing New Licenses
License Detail View
Order Detail View
Customer Detail View
Metadata
Analytics
Settings
Product Configuration
Product Features
Product Custom Fields
Product Versioning
License Policies
Product Bundles
License Entitlements
License Types
Activations & Device Transfers
Features
Custom Fields
License Start Date
License Note
Maintenance Period
Trial Licenses
Floating Licenses
License Activation Types
Portals
End-User Portal
Offline Portal
Air-Gapped Portal
License API
License API Authorization
License Activation/Deactivation
License Check
Consumption
Floating
Trial Key
Product Details
Device Variables
Changing Password
Management API
Making API Requests
Management API Authorization
Customer
Product
Order
License
Device
Analytics
SDKs
Tutorials
.NET/C# SDK
.NET/C# Management SDK
C++ SDK
Java SDK
Python SDK
Go SDK
Delphi SDK
Swift/Objective-C SDK
Android SDK
Unity SDK
Errors and Response Codes
Floating Server
API Reference
Deployment
Configuration
Floating Server UI
Securing the Server
Whitelabeling
FAQ
Floating Server Changelog
Integrations
Salesforce
FastSpring
Stripe
Shopify
Common Scenarios
Single Sign On (SSO)
Glossary
General
SDK Glossary
Vendor Platform
Product Configuration Glossary
License Configuration
Postman Collections
Frequently Asked Questions
Changelog
License API changelog
Platform changelog
Docs powered by
Archbee
SDKs
...
Tutorials
Best Practices

Logging

12min

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
|
// Just set log handler:
LSLog.log = { level, message in
    print("[\(level)] \(message())")
}


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
|
std::string appName = "NAME"; //input name of application
std::string appVersion = "VERSION"; //input version of application

ExtendedOptions options;
options.enableLogging( true ); 

auto configuration = Configuration::Create(
     EncryptStr( "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ),
     EncryptStr( "XXXXXXXXX-XXXXX-XXXXXXXXXXXXX_XXXXXX_XXXXXX" ), 
     EncryptStr( "XXXXXX" ),
     appName, appVersion, options );

auto licenseManager = LicenseManager::create( pConfiguration );


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

C++
C#
Java
|
bool LicenseSpring::ExtendedOptions::isLoggingEnabled()


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
|
var path = licenseManager.DataLocation;


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
|
LicenseSpringConfiguration.ClientConfigurationBuilder licenseFilePath( String licenseFilePath )


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.



Updated 05 Sep 2023
Did this page help you?
PREVIOUS
Virtual Machine Detection
NEXT
License Features
Docs powered by
Archbee
TABLE OF CONTENTS
Prerequisites
Enabling Logging and Verifying Its Status
Location of the Log File
Default Location in Different Environments
Getting Current Data Location
Changing Data Location
Docs powered by
Archbee