This may be a duplicate of Weird Error: CLOSE BY CLIENT STACK TRACE But I've asked a new question because I don't see isLoggable method for Log. I'm using Logger class of org.apache.log4j.Logger for my log purpose.
My error is same
java.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:566)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
My code is
public JSONObject getUserDetails(int id) {
System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
long lStartTime = new Date().getTime();
JSONObject obj = new JSONObject();
try (Session session = factory.openSession()) {
Employee emp = (Employee) session.load(Employee.class, id);
if (emp != null) {
obj.put("id", emp.getId());
obj.put("name", emp.getName());
}
long lEndTime = new Date().getTime();
log.info("[ Personal Details ]Time elapsed For Fetching :"
+ (lEndTime - lStartTime));
} catch (Exception e) {
log.error(e);
}
return obj;
}
Edit :
My implentation is :
public class PersonalisationImpl implements PersonalisationDao {
private void close( Throwable cause ) throws SQLException
{
close( cause, false );
}
private void close(Throwable cause, boolean b) {
// TODO Auto-generated method stub
assert Thread.holdsLock( this );
if ( logger.isLoggable( MLevel.FINEST ) )
logger.log( MLevel.FINEST, this + " closed by a client.",
new Exception("DEBUG -- CLOSE BY CLIENT STACK TRACE") );
}
Where should I write the method of isLoggable method in the code and which logger class should I use?