KotlinKotlin SDK Troubleshooting Guide

Pubnub implements swappable logging using SLF4J, which allows you to switch different logging frameworks easily. All the logging calls using SLF4J API will be delegated to the underlying logging framework.

setLogVerbosity to PNLogVerbosity.BODY. For more info on configuration, please check the API reference page.

val pnConfiguration = PNConfiguration()
pnConfiguration.logVerbosity = PNLogVerbosity.BODY

To implement logging on Android you need to add the following dependency to the project.

The logs will appear in Logcat.

To implement logging using log4j you need to add the following references to the project. Using log4j you can log to console or a file or both.

Along with these references you need to add the log4j.properties file in the CLASSPATH

# Root logger option
log4j.rootLogger=ALL, FILE

# Direct log messages to a log file
log4j.appender.FILE =org.apache.log4j.FileAppender
log4j.appender.FILE.File=/Users/rajat/Projects/eclipsews/log4jloging.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=DEBUG
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %m%n

More info can be found here.

To implement logging using slf4j you need to add the following references to the project.

Along with these references you need to add the simplelogger.properties file in the CLASSPATH.

org.slf4j.simpleLogger.logFile=System.out
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS

To implement logging using logback-classic you need to add the following references to the project.

To implement logging using java.util.logging you need to add the following references to the project.

JVM runtime provides the underlying logging framework.

To implement logging using commons-logging you need to add the following references to the project.

The underlying logging framework is chosen dynamically by commons-logging.

To implement no logging you have two options: