How To Cook Java.Io.Notserializableexception: Org.Apache.Log4j.Logger Fault Inwards Java
Monday, June 11, 2018
Add Comment
java.io.NotSerializableException: org.apache.log4j.Logger fault says that lawsuit of org.apache.lo4j.Logger is non Serializable. This fault comes when nosotros role log4j for logging inwards Java as well as practise Logger inwards a Serializable aeroplane e.g. whatsoever domain aeroplane 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 convey a non serializable aeroplane every bit fellow member inwards a Serializable class, it volition throw java.io.NotSerializableException Exception.
Look at the below code :
public aeroplane Customer implements Serializable{
private Logger logger = Logger.getLogger(Customer.class)
......
}
If lawsuit of Customer volition endure stored inwards HttpSession or Serialized externally it volition throw "java.io.NotSerializableException: org.apache.log4j.Logger" because hither logger lawsuit 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 aeroplane Customer implements Serializable{
private static end Logger logger = Logger.getLogger(Customer.class)
......
}
That's all on how to gear upwards java.io.NotSerializableException: org.apache.log4j.Logger in Java. We convey seen what drive java.io.NotSerializableException: org.apache.log4j.Logger, it's because Logger aeroplane is non Serializable only nosotros likewise learned that at that topographic point is no quest serializing Logger lawsuit as well as meliorate to brand Logger static as well as final.
Further Learning
Complete Java Masterclass
2 ways to solve java.lang.OutOfMemoryError inwards Java
Sumber https://javarevisited.blogspot.com/
0 Response to "How To Cook Java.Io.Notserializableexception: Org.Apache.Log4j.Logger Fault Inwards Java"
Post a Comment