How To Get Java.Io.Notserializableexception: Org.Apache.Log4j.Logger Fault Inwards Java
java.io.NotSerializableException: org.apache.log4j.Logger fault says that illustration of org.apache.lo4j.Logger is non Serializable. This fault comes when nosotros purpose log4j for logging inwards Java as well as practice Logger inwards a Serializable cast e.g. whatever domain cast or POJO which nosotros desire to shop inwards HttpSession or desire to serialize it. As nosotros know from 10 Java Serialization interview question that, if you lot accept a non serializable cast equally fellow member inwards a Serializable class, it volition throw java.io.NotSerializableException Exception.
Look at the below code :
public cast Customer implements Serializable{
private Logger logger = Logger.getLogger(Customer.class)
......
}
If illustration of Customer volition live stored inwards HttpSession or Serialized externally it volition throw "java.io.NotSerializableException: org.apache.log4j.Logger" because hither logger illustration is neither static or transient as well as it doesn't implement Serializable or Externalzable interface.
How to solve java.io.NotSerializableException: org.apache.log4j.Logger

public cast Customer implements Serializable{
private static lastly Logger logger = Logger.getLogger(Customer.class)
......
}
That's all on how to gear upward java.io.NotSerializableException: org.apache.log4j.Logger in Java. We accept seen what displace java.io.NotSerializableException: org.apache.log4j.Logger, it's because Logger cast is non Serializable simply nosotros equally good learned that in that location is no indicate serializing Logger illustration as well as amend to brand Logger static as well as final.
Further Learning
Complete Java Masterclass
2 ways to solve java.lang.OutOfMemoryError inwards Java
Belum ada Komentar untuk "How To Get Java.Io.Notserializableexception: Org.Apache.Log4j.Logger Fault Inwards Java"
Posting Komentar