org.apache.logging.log4j.spring.boot.ext.Log4jJdbcConnectionSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of log4j2-plus-spring-boot-starter Show documentation
Show all versions of log4j2-plus-spring-boot-starter Show documentation
Spring Boot Starter For Log4j 2.x
package org.apache.logging.log4j.spring.boot.ext;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.logging.log4j.core.appender.db.jdbc.AbstractConnectionSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 使用已有数据源作为连接获取基础
*/
public class Log4jJdbcConnectionSource extends AbstractConnectionSource {
private static Logger LOG = LoggerFactory.getLogger(Log4jJdbcConnectionSource.class);
private DataSource dataSource;
public Log4jJdbcConnectionSource(DataSource dataSource){
this.dataSource = dataSource;
}
@Override
public Connection getConnection() throws SQLException {
LOG.debug("Get ");
return dataSource.getConnection();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy