commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Commons Wiki] Update of "Logging/StaticLog" by SimonKitching
Date Fri, 17 Aug 2007 11:30:20 GMT
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:

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
+ 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:
For additional commands, e-mail:

View raw message