commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: Static versus Transient Logger Declarations
Date Fri, 10 Sep 2010 13:15:15 GMT

Ray and crew
other than accomodating a main driver such as public static void main(String args[])  is there
any reason for declaring any method or variable as static?
an intelligent logger (log4j) could reconfigure the appenders to redeploy CPU-intensive/memory-intensive/IO
intensive (logging) operations to resources which can handle these loads (e.g. sockets)
     Logger root_logger = Logger.getRootLogger();
     {  //we dont want to bog down PRODUCTION appServer with lots of File IO so we'll send
the logs to an external socket
           SocketAppender sock_appender = new SocketAppender(host, port);  //assume host and
port have been verified for the AppServer
   {   //standard DailyRollingFileAppender (caution this is IO intensive)!
       DailyRollingFileAppender rolling_appender = new DailyRollingFileAppender();
     int k=0;
      logger.debug("Message " + k++);"Info " + k++);
      logger.warn("Warn " + k++);
      logger.error("Error " + k++, new Exception("Just testing"));
      catch(Exception e) 
        System.err.println("problem with Logger exception is"+e.getMessage());
Martin Gainty 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Ez az üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy jelentse
azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem megengedett.
 Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi alkalmazhatósága sincs.
 Mivel az electronikus üzenetek könnyen megváltoztathatóak, ezért minket semmi felelöség
nem terhelhet ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.


> From:
> To:
> Date: Fri, 10 Sep 2010 08:16:41 -0400
> Subject: RE: Static versus Transient Logger Declarations
> I guess that aspect of it comes down to a personal philosophy more than anything else.
I typically try to help things like this bubble up so the knowledge can be shared and pain
can be avoided in a proactive way instead of waiting for others to learn for themselves. So
that's why I'm asking for other communities to engage. I'm not actually trying to challenge
the JBoss contributors directly, or cause any "religious" wars over best practices. I just
want to see some solid reasoning on the topic so we can get the correct knowledge out there
and either validate the currently accepted practice, or confirm that this other strategy should
be the best practice. Once the correct knowledge is out there, then each community can make
solid design decisions instead of succumbing to the "cargo cult code" phenomenon that seems
to be responsible for the current strategy that people think is a best practice only because
they see the pattern so frequently.
> I'm not really worried about it, for the reasons you mentioned, but I do want to see
the "experts" in this area at least defend or amend the Apache Commons Wiki content if it
turns out to be bad information (as some in the aforementioned thread seem to indicate).
> Ray
> -----Original Message-----
> From: Adrian Crum [] 
> Sent: Thursday, September 09, 2010 3:54 PM
> To: Commons Users List
> Subject: Re: Static versus Transient Logger Declarations
> I'm not an expert on the subject, but as an outsider looking in, it seems to me that
logging performance is a moot point - since logging is typically used as a debugging tool.
It is unlikely that a high-demand or high-performance application will be doing a lot of logging.
> Also, it seems you are questioning the JBoss contributors best practices in your post.
Why not follow the best practices and let someone else worry about the pros and cons of static
Log instances? If static Log instances cause a configuration problem in certain app containers,
then it will be evident in the bug tracker - and someone down the road will make the appropriate
change to fix the bug.
> In other words, if it was me, I wouldn't worry about it.
> -Adrian
> --- On Thu, 9/9/10, Cardillo, Ray - IS <> wrote:
> > From: Cardillo, Ray - IS <>
> > Subject: Static versus Transient Logger Declarations
> > To: "" <>, ""
> > Date: Thursday, September 9, 2010, 9:27 AM
> > I have recently started a
> > discussion<>
> > about the use of Static versus Transient Logger declarations
> > in open source libraries that are intended to be used in
> > multiple application containers (or other contexts) after
> > reading the following Apache Commons Logging article:
> > 
> > Logging/StaticLog
> >
> > 
> > The article seems sound to me, and does a good job of
> > explaining why Transient is generally the better strategy,
> > should not cause any tangible performance degradation with
> > most modern logging libraries, and more importantly, why it
> > will actually work correctly when used in anything but the
> > simplest Java application.  However, some people have
> > responded to this thread by either focusing on performance
> > (which seems to be a mute point in my opinion) or by
> > focusing on the features of one specific Logger library
> > implementation.  Both perspectives seem to be short
> > sited if you are intending to create a library that can be
> > used in any context (e.g., any application container,
> > application, used by another library, etc).
> > 
> > I am asking for participation from the Apache community
> > because some replies have (politely) discredited or
> > dismissed the Apache article that I referenced.  If the
> > article is in fact out of date, then can someone please
> > verify that, and amend the Apache Commons Wiki?  If the
> > article is not outdated, and is still technically accurate,
> > then can someone who is intimately familiar with this topic
> > step forward and help defend the position, and educate
> > others who might be interested in this topic?  I would
> > like to see the correct strategy employed in future work by
> > this community (and other open source communities) because
> > many open source libraries are incubated under bigger
> > projects like JBoss AS, but intended to be used more widely
> > as well.  I would hate to see the incorrect pattern
> > being proliferated just because it is the "de facto norm"
> > especially if there is an opportunity to help educate
> > everyone about a better approach.
> > 
> > So in summary, I am asking for help getting facts (not
> > opinions) communicated about Static versus Transient Logger
> > declarations, so developers who are creating libraries that
> > are intended to be used in any context (any application
> > container, etc), can have a solid reference about which
> > strategy is best.  Again, for easy reference, the link
> > to the forum discussion is:
> > 
> > Better strategy for instantiation of Logger instances
> > (static causes problems)
> >
> > 
> > 
> > Thanks in advance to anyone who participates!
> > 
> > Ray Cardillo
> > Principal Software Engineer
> > ITT Corporation
> > Advanced Engineering & Sciences (AES)
> > Rome, NY
> > 
> > ________________________________
> > This e-mail and any files transmitted with it may be
> > proprietary and are intended solely for the use of the
> > individual or entity to whom they are addressed. If you have
> > received this e-mail in error please notify the sender.
> > Please note that any views or opinions presented in this
> > e-mail are solely those of the author and do not necessarily
> > represent those of ITT Corporation. The recipient should
> > check this e-mail and any attachments for the presence of
> > viruses. ITT accepts no liability for any damage caused by
> > any virus transmitted by this e-mail.
> > 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message