[Hawkular-dev] Logging ...

John Mazzitelli mazz at redhat.com
Thu Jan 29 14:48:33 EST 2015


Note that the annotation stuff has changed. All the annotations in org.jboss.logging has been deprecated. You need another dep called org.jboss.logging:jboss-logging-annotations - version 1.2.0.Final.

I believe it is not a runtime dependency - so I just put it in my parent pom with provided scope. All the annotations have a retention policy of CLASS, not RUNTIME, so I assume that means you don't need the annotations jar (and, in fact, the Wildfly 8.2 distro does not have it - the only thing in the org.jboss.logging module is the logging jar itself)

In addition, @MessageLogger requires you to specify "projectCode" attribute now. I'm sure there are other changes on the new annotations stuff. The example I found on the RH wiki is for the old annotations, I guess.

----- Original Message -----
> 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.
>   }
> }
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
> 


More information about the hawkular-dev mailing list