How to enable logging for Maverick NG

The Maverick NG API (both client and server) use SLF4J logging. SLF4J is just a logging facade that supports several different types of logging frameworks. Wrappers are available for AVSL, JDK14, Log4J, Logback and Simple (to System.err). It should also be possible to add your own wrapper if you use a custom logging system.

Unlike previous versions of our API, no special debug jar file is required. Use the standard jars and include the SLF4J dependencies from our lib folder. We provide the wrapper for Log4J in our lib folder, slf4j-log4j12-1.7.2.jar. If you want to use a different logging framework then you need to omit this jar file and replace with the relevant wrapper jar from SLF4J website. 

Using Log4J

To configure log4j we use:

org.apache.log4j.PropertyConfigurator.configure("log4j.properties");

with log4j.properties file containing

# Set root category priority to INFO and its only appender to CONSOLE. 
log4j.rootCategory=DEBUG,CONSOLE,LOGFILE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout. 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 
log4j.appender.CONSOLE.Threshold=DEBUG 
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 
log4j.appender.CONSOLE.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %x - %m%n

# LOGFILE is set to be a File appender using a PatternLayout. 
log4j.appender.LOGFILE=org.apache.log4j.FileAppender 
log4j.appender.LOGFILE.File=maverick.log 
log4j.appender.LOGFILE.Append=true 
log4j.appender.LOGFILE.Threshold=INFO 
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.LOGFILE.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %x - %m%n

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.