Apache Directory Project - Logging and Logger Name Conventions

This is Interesting: Free IT Magazines  
Home > Archive > Apache Directory Project > November 2005 > Logging and Logger Name Conventions





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Logging and Logger Name Conventions
Simon.Temple-bNHniqfy2KDk7dXyY5I9mNBPR1lH4CV8@

2005-11-11, 5:45 pm





I have a couple of points on the use of Loggers I'd like opinions on:

1. After embedding the server within JBoss it took a long time to stop the
BERDigester DEBUG messages filling up our log files. By convention most
projects that use logging create loggers using their class names:
LoggerFactory.getLogger( InterceptorChainTest.class ); So controlling
logging system wide is quite intuitive.

The BERDIgester does not follow this convention. It creates a logger with
a fixes name "BERDigester".

org.apache.asn1.ber.digester.BERDigesterLoggingMonitor

Can/should this be changed?

2. I spotted a few calls to log.xxx() which are not wrapped in
log.isxxxEnabled() calls. This can lead to inefficiencies especially when
the log.xxx() call involves String concatenation. See
org.apache.ldap.server.jndi.ServerContextFactory log.info() calls for
examples. Can these be changed?


- Simon Temple


Trustin Lee

2005-11-11, 8:45 pm

Hi Simon,

2005/11/12, Simon.Temple-bNHniqfy2KDk7dXyY5I9mNBPR1lH4CV8@public.gmane.org <Simon.Temple-bNHniqfy2KDk7dXyY5I9mGGXanvQGlWp@public.gmane.orgm
>:
>
> 1. After embedding the server within JBoss it took a long time to stop the
> BERDigester DEBUG messages filling up our log files. By convention most
> projects that use logging create loggers using their class names:
> LoggerFactory.getLogger( InterceptorChainTest.class ); So controlling
> logging system wide is quite intuitive.
>
> The BERDIgester does not follow this convention. It creates a logger with
> a fixes name "BERDigester".
>
> org.apache.asn1.ber.digester.BERDigesterLoggingMonitor



I think you can disable the whole log messages by disabling 'org.apache.asn1'
in Log4J. Am I getting something wrong?

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Alex Karasulu

2005-11-12, 5:45 pm

Simon.Temple-bNHniqfy2KDk7dXyY5I9mNBPR1lH4CV8@public.gmane.org wrote:

>
>
>I have a couple of points on the use of Loggers I'd like opinions on:
>
>1. After embedding the server within JBoss it took a long time to stop the
>BERDigester DEBUG messages filling up our log files. By convention most
>projects that use logging create loggers using their class names:
>LoggerFactory.getLogger( InterceptorChainTest.class ); So controlling
>logging system wide is quite intuitive.
>
>
>

You're right this should be as you say. I have committed a change to
make it so:

revision 332800

>The BERDIgester does not follow this convention. It creates a logger with
>a fixes name "BERDigester".
>
> org.apache.asn1.ber.digester.BERDigesterLoggingMonitor
>
>Can/should this be changed?
>
>
>

Done above.

>2. I spotted a few calls to log.xxx() which are not wrapped in
>log.isxxxEnabled() calls. This can lead to inefficiencies especially when
>the log.xxx() call involves String concatenation. See
>org.apache.ldap.server.jndi.ServerContextFactory log.info() calls for
>examples. Can these be changed?
>
>
>

Sure Simon you are 100% right. I don't think anyone has made it a good
practice to wrap these things. I will make sure I do this all the
time. I will accept and apply any patches that wrap log called with a
conditional to see if the log level is enabled. I will apply it
immediate if you or anyone else can provide them.

Thanks,
Alex


Ceki Gülcü

2005-11-14, 7:45 am

At 06:46 PM 11/12/2005, Alex Karasulu wrote:

>Sure Simon you are 100% right. I don't think anyone has made it a good=20
>practice to wrap these things. I will make sure I do this all the=20
>time. I will accept and apply any patches that wrap log called with a=20
>conditional to see if the log level is enabled. I will apply it immediate=

=20
>if you or anyone else can provide them.


If you are using SLF4J, then wrapping is not necessary. Instead of writing,

if(logger.isDebugEnabled()) {
logger.debug("User name is "+name+".");
}

you can write

logger.debug("User name is {}.", name);

The second form is more convenient, has a smaller footprint (both in memory=
=20
and on disk) and is slightly faster.

For more details, please refer to http://www.slf4j.org/faq.html#2.3

I hope this helps,

>Thanks,
>Alex


--=20
Ceki G=FClc=FC

The complete log4j manual: http://www.qos.ch/log4j/
Improve your Sudoku skills at http://www.sudoku-grok.com/



Alex Karasulu

2005-11-14, 5:45 pm

Ceki Gülcü wrote:

> At 06:46 PM 11/12/2005, Alex Karasulu wrote:
>
>
>
> If you are using SLF4J, then wrapping is not necessary. Instead of
> writing,
>
> if(logger.isDebugEnabled()) {
> logger.debug("User name is "+name+".");
> }
>
> you can write
>
> logger.debug("User name is {}.", name);
>
> The second form is more convenient, has a smaller footprint (both in
> memory and on disk) and is slightly faster.
>
> For more details, please refer to http://www.slf4j.org/faq.html#2.3
>
> I hope this helps,


Thanks again Ceki. I forgot that this second overload actually does the
check for us. Good thing to point out yet again and again. I'm sure
people will gravitate as I did to the old way.

Alex



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com