Logging practices
Logging is an essential part of application development and maintenance that lets you monitor real-time activities and diagnose issues effectively. By enabling logging, you can gain insights into your application behavior and maintain audit trails for security and compliance purposes.
PubNub supports logging by providing configuration options in most SDKs to enable and control the level of logging output.
If a given SDK supports logging, you can find detailed information on how to enable and configure it in the Troubleshooting section of each SDK documentation, like in the JavaScript SDK.
Logging options
Here's an overview of the available SDK logging options:
-
Configuration options: Most PubNub SDKs let you enable logging by setting specific configuration properties, such as
logVerbosity
. -
Log levels: Many SDKs offer multiple log levels (e.g., debug, info, warn, error) that you can set to control the verbosity and type of logged information.
-
Output destinations: Some PubNub SDKs provide flexibility in specifying where log outputs should be directed, such as to the console, files, or custom destinations, by integrating with various logging frameworks or libraries.
-
Custom logging: Similarly, in some SDKs you can implement custom loggers or handlers to route logs to databases or other storage systems by using the SDKs' interfaces or hooks.
-
Standard libraries: Selected SDKs use industry-standard logging libraries like SLF4J, allowing integration with other logging frameworks like Log4j, to facilitate logging across different environments and platforms.