Commit f640cfb9 by cjh
parents f647cbf6 842d76a4
......@@ -24,6 +24,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- spring版本号 -->
<spring.version>5.1.3.RELEASE</spring.version>
<log4j2.version>2.12.1</log4j2.version>
</properties>
<dependencies>
......@@ -290,7 +291,6 @@
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
......@@ -302,6 +302,31 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>cfca.integration</groupId>
<artifactId>SADK</artifactId>
<version>3.2.0.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.23</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
</dependency>
</dependencies>
<build>
<finalName>business</finalName>
......
......@@ -22,8 +22,6 @@
</service>
-->
<service class="org.sss.module.hibernate.HibernateUtils" initMethodName="init" deinitMethodName="deinit">
<!-- 生成代码基本包名(不可修改) -->
<property name="packageName" value="com.brilliance.eibs.etrade" />
<!-- 生成数据库脚本(设置全路径或相对路径,生成出来作为参考,为空则不生成) -->
<property name="scriptFile" value="/Users/JasonHoo/Downloads/eIBS.sql" />
<!-- 自动重建数据库表 -->
......
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%-10t] %-5level %c{1} %ex{full} - %msg%n"/>
</Console>
<!--自定义appender-->
<!-- <XXXFileAppender name="xxx" fileName="log.log" xxx="true">
<PatternLayout pattern="%d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</XXXFileAppender>-->
<JDBC name="databaseAppender" tableName="test.log">
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
<ConnectionFactory class="org.sss.presentation.noui.log.db.ConnectionFactory"
method="getDatabaseConnection"/>
<Column name="ID" literal="'XXX'"/>
<Column name="MESSAGE" pattern="%message"/>
<Column name="LEV" pattern="%level"/>
<Column name="LOGGER" pattern="%logger"/>
<Column name="THROWABLE" pattern="%msg %ex{full}"/>
<Column name="eventDate" isEventTimestamp="true"/>
</JDBC>
</Appenders>
<Loggers>
<!--异步方式入库-->
<!--<AsyncLogger name="org.sss" level="ERROR" includeLocation="true" additivity="false">
<AppenderRef ref="databaseAppender"/>
</AsyncLogger>-->
<!--<Logger name="org.sss" level="INFO" additivity="false">
<Filters>
<ThresholdFilter level="INFO" onMatch="NEUTRAL" onMismatch="DENY"/>
<RegexFilter regex="测试.*" onMatch="NEUTRAL" onMismatch="DENY"/>
<TimeFilter start="05:00:00" end="23:30:00" onMatch="NEUTRAL" onMismatch="DENY"/>
</Filters>
<AppenderRef ref="Console"/>
</Logger>-->
<AsyncLogger name="org.sss" level="INFO" includeLocation="true" additivity="true">
<AppenderRef ref="databaseAppender"/>
</AsyncLogger>
<AsyncLogger name="org.hibernate" level="ERROR" includeLocation="true">
<AppenderRef ref="databaseAppender"/>
</AsyncLogger>
<AsyncLogger name="org.apache" level="ERROR" includeLocation="true">
<AppenderRef ref="databaseAppender"/>
</AsyncLogger>
<AsyncLogger name="com.opensymphony" level="ERROR" includeLocation="true">
<AppenderRef ref="databaseAppender"/>
</AsyncLogger>
<Root level="ALL">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
package org.sss.presentation.noui.log.db;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
public class ConnectionFactory {
private final DataSource dataSource;
private ConnectionFactory() {
Properties properties = new Properties();
properties.setProperty("driverClassName","com.mysql.jdbc.Driver");
properties.setProperty("url","jdbc:mysql://127.0.0.1:3306/test");
properties.setProperty("username","root");
properties.setProperty("password","666666");
properties.setProperty("initialSize","1");
properties.setProperty("maxActive","5");
properties.setProperty("maxWait","3000");
try {
this.dataSource = DruidDataSourceFactory.createDataSource(properties);
} catch (Exception e) {
throw new RuntimeException("创建druid数据源异常",e);
}
}
public static Connection getDatabaseConnection() throws SQLException {
return Singleton.INSTANCE.dataSource.getConnection();
}
private static interface Singleton {
final ConnectionFactory INSTANCE = new ConnectionFactory();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment