You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Cardillo, Ray - IS" <Ra...@itt.com> on 2010/09/09 18:27:06 UTC

Static versus Transient Logger Declarations

I have recently started a discussion<https://community.jboss.org/message/558408#558408> 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
http://wiki.apache.org/commons/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)
https://community.jboss.org/message/558408#558408


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.

Re: Static versus Transient Logger Declarations

Posted by Ted Dunning <te...@gmail.com>.
Take Math.sin as an example.  Should you have to instantiate a Math object
just to compute the sine?

On Fri, Sep 10, 2010 at 8:18 PM, Guy Rouillier <gu...@burntmail.com>wrote:

> On 9/10/2010 9:15 AM, Martin Gainty wrote:
>
>>
>> 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?
>>
>
> Sure.  If you have methods that are self-contained, i.e., use only
> parameters or local variables, then there is little reason *not* to make
> them static.  Why incur the object overhead?
>

Re: Static versus Transient Logger Declarations

Posted by Guy Rouillier <gu...@burntmail.com>.
On 9/10/2010 9:15 AM, Martin Gainty wrote:
>
> 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?

Sure.  If you have methods that are self-contained, i.e., use only 
parameters or local variables, then there is little reason *not* to make 
them static.  Why incur the object overhead?

-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: Static versus Transient Logger Declarations

Posted by Martin Gainty <mg...@hotmail.com>.
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();
     BasicConfigurator.configure();
     try 
     {  //we dont want to bog down PRODUCTION appServer with lots of File IO so we'll send the logs to an external socket
   if(java.lang.System.getEnv("PRODUCTION")!=null)      
   {
           SocketAppender sock_appender = new SocketAppender(host, port);  //assume host and port have been verified for the AppServer
           sock_appender.setName("SocketAppenderLog");
           sock_appender.activateOptions();
           root_logger.addAppender(sock_appender);
   }
   else
   {   //standard DailyRollingFileAppender (caution this is IO intensive)!
       DailyRollingFileAppender rolling_appender = new DailyRollingFileAppender();
       rolling_appender.setName("RollingFileLog");
       rolling_appender.setDatePattern("yyyy-MM-dd.'log'");
       rolling_appender.activateOptions();
       root_logger.addAppender(rolling_appender);
     }   
     int k=0;
      logger.debug("Message " + k++);
      logger.info("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: Ray.Cardillo@itt.com
> To: user@commons.apache.org
> 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 [mailto:adrian.crum@yahoo.com] 
> 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 <Ra...@itt.com> wrote:
> 
> > From: Cardillo, Ray - IS <Ra...@itt.com>
> > Subject: Static versus Transient Logger Declarations
> > To: "log4j-user@logging.apache.org" <lo...@logging.apache.org>, "user@commons.apache.org" <us...@commons.apache.org>
> > Date: Thursday, September 9, 2010, 9:27 AM
> > I have recently started a
> > discussion<https://community.jboss.org/message/558408#558408>
> > 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
> > http://wiki.apache.org/commons/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)
> > https://community.jboss.org/message/558408#558408
> > 
> > 
> > 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: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
 		 	   		  

Re: Static versus Transient Logger Declarations

Posted by Mark Thomas <ma...@apache.org>.
On 10/09/2010 13:29, Leon Rosenberg wrote:
> Hello,
> 
> as to my knowledge the modern containers do not encourage the usage of
> shared data anymore, and this was the only possible problem cause
> anyway:
> 
> The real root cause of this problem is that SHARED data (static
> members on a class) is being shared across supposedly independent
> "applications". If no classes are "shared" between applications then
> the problem does not exist. However it appears that (to my personal
> frustration) container vendors continue to encourage the use of shared
> classes, and application developers continue to use it.
> 
> In other words, if the application developer is dumb enough to put his
> logging library in the shared lib folder of the container he will
> encounter a problem. If he's a brave soul and deploys each webapp
> independtly he will have no problems. Right?
> 
> Since the dumb developer will always find a way to mess stuff up, I
> would say the whole discussion is pointless ;-)

With my Tomcat hat on +1.

Sharing libraries between web applications is a really bad idea in so
many different ways. The benefits (less disk space, less memory) are
very, very rarely worth the associated costs of significantly more
complex upgrades & restarts, scope for memory leaks, etc.

> P.S. talking about modern containers I was referring to tomcat.

Nice to know it is thought of as modern :)

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Static versus Transient Logger Declarations

Posted by Leon Rosenberg <ro...@googlemail.com>.
Hello,

as to my knowledge the modern containers do not encourage the usage of
shared data anymore, and this was the only possible problem cause
anyway:

The real root cause of this problem is that SHARED data (static
members on a class) is being shared across supposedly independent
"applications". If no classes are "shared" between applications then
the problem does not exist. However it appears that (to my personal
frustration) container vendors continue to encourage the use of shared
classes, and application developers continue to use it.

In other words, if the application developer is dumb enough to put his
logging library in the shared lib folder of the container he will
encounter a problem. If he's a brave soul and deploys each webapp
independtly he will have no problems. Right?

Since the dumb developer will always find a way to mess stuff up, I
would say the whole discussion is pointless ;-)

best regards
Leon

P.S. talking about modern containers I was referring to tomcat.


On Fri, Sep 10, 2010 at 2:16 PM, Cardillo, Ray - IS
<Ra...@itt.com> wrote:
> 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 [mailto:adrian.crum@yahoo.com]
> 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 <Ra...@itt.com> wrote:
>
>> From: Cardillo, Ray - IS <Ra...@itt.com>
>> Subject: Static versus Transient Logger Declarations
>> To: "log4j-user@logging.apache.org" <lo...@logging.apache.org>, "user@commons.apache.org" <us...@commons.apache.org>
>> Date: Thursday, September 9, 2010, 9:27 AM
>> I have recently started a
>> discussion<https://community.jboss.org/message/558408#558408>
>> 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
>> http://wiki.apache.org/commons/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)
>> https://community.jboss.org/message/558408#558408
>>
>>
>> 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: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: Static versus Transient Logger Declarations

Posted by "Cardillo, Ray - IS" <Ra...@itt.com>.
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 [mailto:adrian.crum@yahoo.com] 
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 <Ra...@itt.com> wrote:

> From: Cardillo, Ray - IS <Ra...@itt.com>
> Subject: Static versus Transient Logger Declarations
> To: "log4j-user@logging.apache.org" <lo...@logging.apache.org>, "user@commons.apache.org" <us...@commons.apache.org>
> Date: Thursday, September 9, 2010, 9:27 AM
> I have recently started a
> discussion<https://community.jboss.org/message/558408#558408>
> 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
> http://wiki.apache.org/commons/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)
> https://community.jboss.org/message/558408#558408
> 
> 
> 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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Static versus Transient Logger Declarations

Posted by Adrian Crum <ad...@yahoo.com>.
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 <Ra...@itt.com> wrote:

> From: Cardillo, Ray - IS <Ra...@itt.com>
> Subject: Static versus Transient Logger Declarations
> To: "log4j-user@logging.apache.org" <lo...@logging.apache.org>, "user@commons.apache.org" <us...@commons.apache.org>
> Date: Thursday, September 9, 2010, 9:27 AM
> I have recently started a
> discussion<https://community.jboss.org/message/558408#558408>
> 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
> http://wiki.apache.org/commons/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)
> https://community.jboss.org/message/558408#558408
> 
> 
> 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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org