At 04:58 PM 9/29/2003 +0800, Yu Xiang Xi (Maveo) wrote:
I have seen different usage of initial log4j instance like below
private final static Logger logger = Logger.getLogger("some.name");

looks good.


        and
private final transient static Logger logger =
Logger.getLogger("some.name");
the second one has a additional keyword transient.

Loggers cannot be serialized so marking them transient can be useful for non static loggers.


However, since static variables are not serialized, there is no need to mark them as transient.

Moreover, in addition to serialization aspects, the keyword 'transient' has other meanings. It forces the JVM to re-reread the value of the variable from memory for each access, adding unnecessary overhead.

Which way is recommended?

The recommended form is:


private static final Logger logger = ...


Thanks in advance.

Best Regards
Xi Yuxiang
Maveo Systems Limited

-- Ceki Gülcü

     For log4j documentation consider "The complete log4j manual"
     ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp

     import org.apache.Facetime;
     ApacheCon US 2003, 18-21 November http://apachecon.com/



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



Reply via email to