Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for 
change notification.

The following page has been changed by SimonKitching:
http://wiki.apache.org/jakarta-commons/Logging/StaticLog

The comment on the change is:
Add info about fixing existing code

------------------------------------------------------------------------------
  actually turns up logging to debug on ''all'' applications, though output 
from applications other than
  the one of interest is then suppressed again before being output.
  
+ == Fixing Existing Library Code ==
+ 
+ If you already have some library-type code that uses static log objects, and 
want to fix it after reading
+ this page, be careful of one issue: changing a static member to a non-static 
one changes the
+ serialization format of the class. The serialVersionUID of the class must 
change, and
+ as a result serialized versions of the old class will not load.
+ 
+ A possible (untested) alternative is to add a method like this:
+ {{{
+   private transient Log log;
+   private Log getLog() {
+     if (log == null)
+       log=LogFactory.getLog(Some.class);
+     return log;
+   }
+ 
+   // old code
+   // log.debug("foo");
+ 
+   // new code
+   getLog().debug("foo");
+ }}}
+ 
+ Like static members, transient ones are not part of the serialized data so 
this should be
+ a serialization-compatible change.
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to