Log4j and Serializable classes
Hi, Log4j works in objects that implements Serializable? If so, how this is possible? If a client receives an object from the server that implements Serializable, how the client knows how to interpret log4j instructions? Sincerely, Pedro - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Log4j and Serializable classes
I don't quite understand. Do you want to serialize log4j classes? Anytime that you serialize an object both the client and server need all classes that the object uses. If the object has a log4j Logger than both the client and server should have log4j.jar in the classpath. On 1/22/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Log4j works in objects that implements Serializable? If so, how this is possible? If a client receives an object from the server that implements Serializable, how the client knows how to interpret log4j instructions? Sincerely, Pedro - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Log4j and Serializable classes
At 10:13 AM 1/22/2007, you wrote: Hi, Log4j works in objects that implements Serializable? If so, how this is possible? If a client receives an object from the server that implements Serializable, how the client knows how to interpret log4j instructions? Log4j Loggers are not Serializable. You must make them either static variables or make them transient. If it's static, then you don't need to do much else. If it's transient, then you'll need to make sure you re-initialize the instance in readObject(), otherwise it will be null (or default value if it's a primitive) in the deserialized object. I suggest you read up on serializtion http://www.churchillobjects.com/c/11009.html Jake Sincerely, Pedro - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Log4j and Serializable classes
On Jan 22, 2007, at 10:13 AM, [EMAIL PROTECTED] wrote: Hi, Log4j works in objects that implements Serializable? If so, how this is possible? If a client receives an object from the server that implements Serializable, how the client knows how to interpret log4j instructions? Sincerely, Pedro I am not sure I understand your question. The most common pattern of using log4j is for a class to have a static member representing to logger, something like: class MyClass implements Serializable { private static final Logger logger = Logger.getLogger (MyClass.class); ... } With this pattern, the logger is not an instance variable of the class and is not serialized with the class. On the receiving end, the value of MyClass.logger will be initialized when MyClass is loaded which may be when the first instance of the class is deserialized. The log4j.jar will need to be on the classpath for the receiving application. If log4j has not been configured before deserializing, the receiving application will be configured following the default configuration pattern (that is looking for log4j.properties and log4j.xml). It would be totally possible for the logger on the sending end to have a different threshold than on the receiving end. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]