Home  >  Article  >  Database  >  [简单]log4jdbc-log4j2配置简记_MySQL

[简单]log4jdbc-log4j2配置简记_MySQL

不言
不言Original
2018-05-26 15:36:522527browse

       log4jdbc-log4j2,就不多说了,不了解的可以谷歌,附上log4jdbc-log4j2的官方链接:

       https://code.google.com/p/log4jdbc-log4j2/ ,上面有非常详细的介绍。

        简单的贴下配置文件,其他的见附件:

        database.properties:

#driverClassName=com.mysql.jdbc.DriverdriverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy#url=jdbc:mysql://localhost:3306/test?characterEncoding=utf8url=jdbc:log4jdbc:mysql://localhost:3306/test?characterEncoding=utf8user_name=rootpassword=123

    application.xml 

<bean id="dataSourceSpied" class="org.apache.commons.dbcp.BasicDataSource"		p:driverClassName="${driverClassName}" p:url="${url}" p:username="${user_name}"		p:password="${password}" />			<bean id="dataSource" class="net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy">		<constructor-arg ref="dataSourceSpied" />	</bean>	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">		<!-- 数据源 -->		<property name="dataSource" ref="dataSource" />		<!-- myBatis配置文件 -->		<property name="configLocation" value="classpath:mybatis-config.xml" />		<!-- 可以在Configuration.xml或此处配置映射文件,但其中不能有相同id的parameterMap, resultMap或sql等 -->		<property name="mapperLocations" value="classpath*:mapper/*.xml" />		<property name="typeAliasesPackage" value="com.bean" />	</bean>

    lib架包没有上传,使用了Spring,Mybatis,Mysql,Log4j,Slf4j。

    效果如下:

    全文完。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn