[Hawkular-dev] Logging ...

Heiko W.Rupp hrupp at redhat.com
Wed Jan 28 06:48:26 EST 2015


Hey,

We should / need to start using logging codes just like Wildfly does.

11:19:27,714 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
11:19:27,716 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.

We have two options here

1) 
We  use "HAWK" as our prefix and the following  code ranges initially

0-999  Hawkular (integration)
1000-1999 Hawkular-Metrics
2000-2999 Hawkular-Alerts (notifiers should probably be broken out in separate blocks)
3000-3999 Hawkular-Inventory
4000-4999 Hawkular-Bus

2)
We use a prefix per component (e.g. HAWK, HKMET, HKAL, ...) and each component has its own code range starting
at 0 

Personally I prefer option 1

There is already documentation on this available

	• https://developer.jboss.org/wiki/HowToLogInJBossProjectshttps://developer.jboss.org/wiki/InternationalizedLoggingAndExceptionshttps://developer.jboss.org/wiki/JBossLoggingTooling

While the documentation and examples look a bit complicated, I think we can "reduce" them for
our purpose for Warnings and Errors and do not need them on debug/trace level.
For info level I guess one should personal judgement (and then if it is not important enough for
its own code, it is probably not really something at info, but rather at debug level).

In practice we would probably end up with something like:

import org.jboss.logging.*;
public interface RestApiLogger {

    RestApiLogger LOGGER = Logger.getMessageLogger(RestApiLogger.class,"org.hawkular.inventory.rest");

    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 3000, value = "Something bad has happened")
    void warn(@Cause Throwable t);

  < plus much more refined messages here >
}

and then in code

} catch (Exception e) {
    RestApiLogger.LOGGER.warn(e);
    return Response.serverError().entity(e).build();
}



-- 
Reg. Adresse: Red Hat GmbH, Technopark II, Haus C, 
Werner-von-Siemens-Ring 14, D-85630 Grasbrunn
Handelsregister: Amtsgericht München HRB 153243
Geschäftsführer: Charles Cachera, Michael Cunningham, Paul Hickey, Charlie Peters




More information about the hawkular-dev mailing list