Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.commons.logging;
 
 import static org.jboss.logging.Logger.Level.ERROR;
 import static org.jboss.logging.Logger.Level.WARN;
 
Infinispan's log abstraction layer on top of JBoss Logging.

It contains explicit methods for all INFO or above levels so that they can be internationalized. For the commons module, message ids ranging from 0901 to 1000 inclusively have been reserved.

Log log = LogFactory.getLog( getClass() ); The above will get you an instance of Log, which can be used to generate log messages either via JBoss Logging which then can delegate to Log4J (if the libraries are present) or (if not) the built-in JDK logger.

In addition to the 6 log levels available, this framework also supports parameter interpolation, similar to the JDKs java.lang.String.format(java.lang.String,java.lang.Object[]) method. What this means is, that the following block: if (log.isTraceEnabled()) { log.trace("This is a message " + message + " and some other value is " + value); }

... could be replaced with ...

if (log.isTraceEnabled()) log.tracef("This is a message %s and some other value is %s", message, value);

This greatly enhances code readability.

If you are passing a Throwable, note that this should be passed in before the vararg parameter list.

Author(s):
Manik Surtani
Since:
4.0
@MessageLogger(projectCode = "ISPN")
public interface Log extends BasicLogger {
   @LogMessage(level = )
   @Message(value = "Property %s could not be replaced as intended!", id = 901)
   @LogMessage(level = )
   @Message(value = "Invocation of %s threw an exception %s. Exception is ignored.", id = 902)
   void ignoringException(String methodNameString exceptionName, @Cause Throwable t);
   @LogMessage(level = )
   @Message(value = "Unable to set value!", id = 903)
   @Message(value = "Error while initializing SSL context", id = 904)
   @LogMessage(level = )
   @Message(value = "Unable to load %s from any of the following classloaders: %s", id=905)
   void unableToLoadClass(String classnameString classloaders, @Cause Throwable cause);
   @LogMessage(level = )
   @Message(value = "Unable to convert string property [%s] to an int! Using default value of %d", id = 906)
   void unableToConvertStringPropertyToInt(String valueint defaultValue);
   @LogMessage(level = )
   @Message(value = "Unable to convert string property [%s] to a long! Using default value of %d", id = 907)
   void unableToConvertStringPropertyToLong(String valuelong defaultValue);
   @LogMessage(level = )
   @Message(value = "Unable to convert string property [%s] to a boolean! Using default value of %b", id = 908)
   void unableToConvertStringPropertyToBoolean(String valueboolean defaultValue);
   @Message(value = "Unwrapping %s to a type of %s is not a supported", id = 909)
New to GrepCode? Check out our FAQ X