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 completed the getting started docid\ lsfy9tq3vfq4roow9shkd 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 void licensespring extendedoptions enablelogging( bool enable ) bool licensespring extendedoptions enableloggingpublic b requestlogging( feign logger level requestlogging )// just set log handler lslog log = { level, message in print("\[\\(level)] \\(message())") }import logging \# configure logging logging basicconfig( filename='app log', # name of the log file filemode='a', # append to the file ('w' for overwrite) format='%(asctime)s %(levelname)s %(message)s', # log format level=logging info # log level (debug, info, warning, error, critical) ) 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 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 );var options = new licensespring extendedoptions(); options enablelogging = true; var configuration = new licensespring configuration( apikey "xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxx", sharedkey "xxxxxxxxx xxxxx xxxxxxxxxxxxx xxxxxx xxxxxx", productcode "xxxxxx", 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 ) build(); licensemanager licensemanager = licensemanager getinstance(); licensemanager initialize( configuration );from licensespring licensefile config import configuration from licensespring licensefile license manager import licenseid, licensemanager import logging \# configure logging logging basicconfig( filename='path where you want to store logs/app log', # name of the log file filemode='a', # append to the file ('w' for overwrite) format='%(asctime)s %(levelname)s %(message)s', # log format level=logging info # log level (debug, info, warning, error, critical) ) conf = configuration( product="your product short code", api key="api key", shared key="shared key", file key="your file key", file iv="file iv", grace period conf=12, is guard file enabled=true) lm = licensemanager(conf) license id = licenseid from key("9ffa 2xzc sndj 49lk") license = lm activate license(license id) license check() developers can chack for whether logging is enabled in the current configuration through using bool licensespring extendedoptions isloggingenabled()bool licensespring configuration isloggingenabledfeign logger level getrequestlogging() 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 std wstring path = licensemanager >licensefilepath();var path = licensemanager datalocation;string path = configuration getlicensefilepath();path = lm data location() 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 licensemanager >setdatalocation(l"new/path/to/licensespring/data");licensemanager datalocation = "new/path/to/licensespring/data";licensespringconfiguration clientconfigurationbuilder licensefilepath( string licensefilepath )lm set data location("new/path/to/licensespring/data") 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