[infinispan-dev] cache name in logs

Mircea Markus mircea.markus at jboss.com
Fri Apr 29 12:37:16 EDT 2011


On 29 Apr 2011, at 16:30, Dan Berindei wrote:

> JBoss Logging does support MDC:
> http://community.jboss.org/wiki/UsingMDCInJBossAS6Applications
> 
> It's not exactly what Mircea wants though, because the decision to
> include or not the cache name in the log will be at the appender level
> and not at the logger level. So all the log messages will include the
> cache name, not just the messages for some of the components.
> 
> Dan
Indeed, for the format element [%X{cacheName}] that would cause an empty "[]" to be displayed when cacheName is not present.
Would be nice if the formatter can be set to ignore the whole "[%X{cacheName}]" if cacheName is not present. Not sure that's possible though.
A workaround would be to move part of the formatting in the MDC param itself: 

MDC.put("cacheName", "["+cacheName + "]);
try {
   do user stuff;
} finally {
   MDC.remove("cacheName");
}

and the formatter won't include the square braces: "%X{cacheName}" instead of [%X{cacheName}]

> 
> 
> On Fri, Apr 29, 2011 at 5:55 PM, Galder Zamarreño <galder at redhat.com> wrote:
>> 
>> On Apr 28, 2011, at 11:47 PM, Manik Surtani wrote:
>> 
>>> We do now support JBoss Logging.
>>> 
>>> https://issues.jboss.org/browse/ISPN-380
>>> 
>>> @Galder, does JBoss Logging have support for what Mircea mentioned below?
>> 
>> I've skimmed through the javadoc but didn't see anything in particular for this at least around the message loggers which are the ones that help with internationalization.
>> 
>> I think it could be fitted but would require a fair amount of changes, such as making some static loggers, particularly those for named cache components non static in order to take the cache name. Maybe you could have a named cache component for a log factory?
>> 
>> The other potential can of worms here is when multiple cache managers are in action (i.e. managed environments) and you have multiple cache managers with same cache names. You could end up having to put cache manager as well and this could get too verbose. It could maybe be configurable somehow.
>> 
>> David, any other ideas?
>> 
>>> 
>>> On 27 Apr 2011, at 13:21, Olaf Bergner wrote:
>>> 
>>>> Silly me, forgot the link: http://logback.qos.ch/manual/mdc.html.
>>>> 
>>>> Am 27.04.11 16:55, schrieb Mircea Markus:
>>>>> Hi,
>>>>> 
>>>>> I'm looking into some logs for the a JBW demo : it has 4 caches deployed on each node and lots of topology changes happen. It's close to impossible to tell  which log pertains to which cache, especially around the DistributionInterceptorImpl.
>>>>> Wouldn't it make sense that, for certain components, to include the name of the cache in the logs? IThis might be achieved with minimal changes by adding an additional param to the LogFactory.getLog(Class) method and let the logger itself do the heavy lifting.
>>>>> e.g.
>>>>> Log l = LogFactory.getLog(DistributionManagerImpl.class, "cacheName");
>>>>> and on each call l.trace("A message") the logger might output, besides underlying log's format, the string "[cacheName] A message".
>>>>> 
>>>>> Wdyt?
>>>>> Cheers,
>>>>> Mircea
>>>>> _______________________________________________
>>>>> infinispan-dev mailing list
>>>>> infinispan-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>>>>> 
>>>> 
>>>> _______________________________________________
>>>> infinispan-dev mailing list
>>>> infinispan-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>>> 
>>> --
>>> Manik Surtani
>>> manik at jboss.org
>>> twitter.com/maniksurtani
>>> 
>>> Lead, Infinispan
>>> http://www.infinispan.org
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> infinispan-dev mailing list
>>> infinispan-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>> 
>> --
>> Galder Zamarreño
>> Sr. Software Engineer
>> Infinispan, JBoss Cache
>> 
>> 
>> _______________________________________________
>> infinispan-dev mailing list
>> infinispan-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>> 
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev




More information about the infinispan-dev mailing list