[Hawkular-dev] Logging ...

John Mazzitelli mazz at redhat.com
Wed Jan 28 11:26:18 EST 2015


This page shows how you can put this in your pom.xml to process the message bundles:

https://developer.jboss.org/wiki/JBossLoggingTooling#jive_content_id_mavenprocessorplugin

And this is a good snippet that shows how org.jboss.logging is used:

@MessageLogger("JBREM")  
public interface MyLogger {  
   @Message(id = 1, value = "JBoss Remoting version %s")  
   @LogMessage(level = INFO)  
   void greet(String version);  
  
   @Message(id = 2, value = "Error connecting from %s to %s: %s")  
   @LogMessage(level = ERROR)  
   void connectionError(SocketAddress src, SocketAddress dst, String reason);  
  
   // trace stuff has different restrictions  
   @Message(value = "Connection established from %s to %s")  
   @LogMessage(level = TRACE)  
   void connectionEstablished(SocketAddress src, SocketAddress dst);  

    // THIS SHOWS USING @Cause
    @LogMessage(level = Level.ERROR)
    @Message(id = 3, value = "Error Message: %s")
    void errorWithCause(@Cause Throwable cause, String error);
}  
  
public class Foo   
{  
  MyLogger log;  
  
  static  
  {  
   log = Logger.getMessageLogger(MyLogger.class, "org.jboss.remoting"); // defaults to current locale  
   log.greet(getVersionString());  
   // etc.  
  }  
}  


More information about the hawkular-dev mailing list