You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Apache Wiki <wi...@apache.org> on 2007/08/17 13:30:20 UTC
[Commons Wiki] Update of "Logging/StaticLog" by SimonKitching
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: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org