[Hawkular-dev] Logging ...

Thomas Heute theute at redhat.com
Wed Jan 28 07:32:19 EST 2015


Luckily we won't have to enter a long debate as some has been formalized 
already here: https://mojo.redhat.com/docs/DOC-65954 ;)

(Sorry it's an internal document)

Thomas


On 01/28/2015 12:57 PM, Lucas Ponce wrote:
> And what about the logging packages ?
>
>> import org.jboss.logging.*;
> vs
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> I personally vote for org.slf4j.
>
> I prefer a mix on option 1) and 2), a common numeration for codes, but each component can still using a specific acronym.
>
> That it can help better to follow traces/logs.
>
> Also, this point can be discussed later, but is there any convention for debug, like this one:
>
>          if (LOG.isDebugEnabled()) {
>              LOG.debug("Message received: [{}]", msg);
>          }
>
> I mean, I like to use DEBUG for verbosity, but to reduce performance penalty, we can discuss a common approach.
>
> Above one is just a suggestion.
>
> Thanks,
> Lucas
>
>
> ----- Original Message -----
>> From: "Heiko W.Rupp" <hrupp at redhat.com>
>> To: hawkular-dev at lists.jboss.org
>> Sent: Wednesday, January 28, 2015 12:48:26 PM
>> Subject: [Hawkular-dev] Logging ...
>>
>> 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/HowToLogInJBossProjects
>>https://developer.jboss.org/wiki/InternationalizedLoggingAndExceptions
>>https://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
>>
>>
>> _______________________________________________
>> hawkular-dev mailing list
>> hawkular-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>>
> _______________________________________________
> 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