使用c3p0在Hibernate中进行客户端堆栈跟踪 [英] CLIENT STACK TRACE in Hibernate using c3p0
问题描述
这可能是>奇怪的错误:通过客户堆栈跟踪CLOSE 但我问了一个新问题,因为我看不到Log的isLoggable方法.我将org.apache.log4j.Logger的Logger类用于我的日志目的.
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.
我的错误是相同的
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)
我的代码是
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;
}
我的专长是:
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") );
}
在代码中应该在哪里编写isLoggable方法的方法,应该使用哪个logger类?
Where should I write the method of isLoggable method in the code and which logger class should I use?
推荐答案
您没有编写isLoggable(...)
方法.日志库中已经存在的文件,并且c3p0对其进行了调用.
you don't write an isLoggable(...)
method. that already exists in the logging library and c3p0 calls it.
您的问题是您正在以TRACE
/FINEST
级别进行日志记录,这意味着您将获得许多不需要的调试信息,包括记录的堆栈跟踪.
your problem is that you are logging at TRACE
/FINEST
levels, which means you are getting a lot of debugging info, including logged stack traces, that you don't want.
您需要弄清楚如何配置用于以com.mchange
开头的库的日志记录库,该库仅用于记录INFO
或更高版本的消息.而已!配置您的日志记录,以便您停止记录调试级别的消息,这将消失.没有问题.您只是记录了太多信息.
you need to figure out how to configure whatever logging library you are using to log only messages at INFO
or above for libraries beginning with com.mchange
. that's it! configure your logging so that you stop logging debug-level messages, and this will go away. there is no problem. you are just logging too much information.
这篇关于使用c3p0在Hibernate中进行客户端堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!