D
Dave V
Hi,
I'm using log4j with a configuration file. I use it to log to a
database table. The logging works great. The only problem is that I
end up with a bunch of connections left open all the time. How can I
get these connections to close?
My code looks like something this:
///////////////////////////////////////
public class myClass{
private static Logger coSuccessLog = null ;
private static Logger coErrorLog = null;
public void logTest() throws Exception {
try {
InputStream boInputStream =
this.getClass().getResourceAsStream("/log4j_lai.properties");
Properties boLog4jProps = new Properties();
boLog4jProps.load(boInputStream);
PropertyConfigurator.configure(boLog4jProps);
coErrorLog =
Logger.getLogger("error."+this.getClass().getName());
coSuccessLog =
Logger.getLogger("success."+this.getClass().getName());
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException ex) {
throw ex;
} catch (IOException ex) {
throw ex;
}
coSuccessLog.info(new java.util.Date() + "made it into
logTest.");
}
}
/////////////////////////////////////// The config file looks like
this:///////////////////////////////////
log4j.category.error=info, R
log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.R.URL=jdbcracle:thinqeweb.lordabbett.com:1521:qeweb
log4j.appender.R.user=mi
log4j.appender.R.password=mi
log4j.appender.R.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'E', SYSDATE)
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.category.success=info, S
log4j.appender.S=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.S.URL=jdbcracle:thinqeweb.lordabbett.com:1521:qeweb
log4j.appender.S.user=mi
log4j.appender.S.password=mi
log4j.appender.S.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'I', SYSDATE)
log4j.appender.S.layout=org.apache.log4j.PatternLayout
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Anyone have a clue? Obviously I don't!
Thanks,
Dave
I'm using log4j with a configuration file. I use it to log to a
database table. The logging works great. The only problem is that I
end up with a bunch of connections left open all the time. How can I
get these connections to close?
My code looks like something this:
///////////////////////////////////////
public class myClass{
private static Logger coSuccessLog = null ;
private static Logger coErrorLog = null;
public void logTest() throws Exception {
try {
InputStream boInputStream =
this.getClass().getResourceAsStream("/log4j_lai.properties");
Properties boLog4jProps = new Properties();
boLog4jProps.load(boInputStream);
PropertyConfigurator.configure(boLog4jProps);
coErrorLog =
Logger.getLogger("error."+this.getClass().getName());
coSuccessLog =
Logger.getLogger("success."+this.getClass().getName());
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException ex) {
throw ex;
} catch (IOException ex) {
throw ex;
}
coSuccessLog.info(new java.util.Date() + "made it into
logTest.");
}
}
/////////////////////////////////////// The config file looks like
this:///////////////////////////////////
log4j.category.error=info, R
log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.R.URL=jdbcracle:thinqeweb.lordabbett.com:1521:qeweb
log4j.appender.R.user=mi
log4j.appender.R.password=mi
log4j.appender.R.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'E', SYSDATE)
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.category.success=info, S
log4j.appender.S=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.S.URL=jdbcracle:thinqeweb.lordabbett.com:1521:qeweb
log4j.appender.S.user=mi
log4j.appender.S.password=mi
log4j.appender.S.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'I', SYSDATE)
log4j.appender.S.layout=org.apache.log4j.PatternLayout
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Anyone have a clue? Obviously I don't!
Thanks,
Dave