Just to know.... Why a static variable is not serializable?

On Sat, Jan 15, 2011 at 7:44 PM, Emmanouil Batsis <ma...@abiss.gr> wrote:

>
>
> Quoting Alexandros Karypidis <akary...@yahoo.gr>:
>
>> I'm using SLF4J and was wondering whether pages should declare:
>>
>>    private transient final Logger log = LoggerFactory
>>            .getLogger(SomePage.class);
>>
>> as members. I guess that accessing a page that was saved and then
>> re-loaded
>> would result in breaking logging, as the variable would be set to null.
>> I've no
>> idea how heavy-weight these Logger implementations are though and am
>> worried
>> that they should not be declared in class scope.
>>
>
> Using static loggers has the benefit of non-serialization between other
> things, including consistency between instances. Making them final and
> private may be appropriate as well. Here's a snippet from our calipso wicket
> app:
>
> /**
>  * Please make proper use of logging, see
>  * http://www.owasp.org/index.php/Category
>  * :Logging_and_Auditing_Vulnerability
>  */
> private static final Logger logger = // call logger factory
>
>
> Cheers,
>
> Manos
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Reply via email to