Logging and Logger Name Conventions
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Directory Project > Logging and Logger Name Conventions




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Logging and Logger Name Conventions  
Simon.Temple-bNHniqfy2KDk7dXyY5I9mNBPR1lH4CV8@


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-11-05 10: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







[ Post a follow-up to this message ]



    Re: Logging and Logger Name Conventions  
Trustin Lee


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-12-05 01:45 AM

Hi Simon,

2005/11/12, Simon.Temple-bNHniqfy2KDk7dXyY5I9mNBPR1lH4CV8@public.gmane.org <Simon.Temple-bNH
niqfy2KDk7dXyY5I9mGGXanvQGlWp@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/






[ Post a follow-up to this message ]



    Re: Logging and Logger Name Conventions  
Alex Karasulu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-12-05 10: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







[ Post a follow-up to this message ]



    Re: Logging and Logger Name Conventions  
Ceki Gülcü


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-14-05 12:45 PM

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/








[ Post a follow-up to this message ]



    Re: Logging and Logger Name Conventions  
Alex Karasulu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-14-05 10: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








[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:56 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register