在 아이디어 4 log4j, 步骤很简单
1. 中加入以下配置 Maven 在
<pectionency> <groupId> Commons-Logging </groupid> <trifactid> Commons-Logging </artifactid> <bersion> 1.2 </version> </fectionency> <pectionement> <groupid> log4j </groupid> <artifactid> log4J </artifactid> <버전> 1.2.16 </dependency> < <groupid> org.slf4j </groupid> <artifactid> slf4j-api </artifactid> <bersion> 1.5.6 </version> <type> jar </type> </fectionency> <pectomency> <groupId> org.slf4j </groupid> <artifactid> slf4j-simple> <version 1.5.6 </6 </6 </version>.
2. mybatis-config.xml 文件
<? xml version = "1.0"encoding = "utf-8"?> <! doctype configuration public "-// mybatis.org//dtd config 3.0 // en" "http://mybatis.org/dtd/mybatis-3-config.dtd"> configuration> <! < ""-> < "-> <f" 값 = "log4j"/> </settings> </configuration>
3. pr log4J.properties 文件
log4j.rootlogger = error, console log4j.logger.com.wocus.wine.dao = debug #consolelog4j.appender.console = org.apache.log4j.consoleapender log4j.appender.console.layout = org.apache.log4j.patternlayout log4j.appender.console.layout.conversionpattern =%d [%t]%-5p [%c] -%m%n
4. Mapper per xml 文件中
<!-Spring 和 mybatis 完美整合 完美整合 完美整合 完美整合 完美整合-> <bean id = "sqlsessionFactory"> <property name = "dataSource"ref = "dataSource"/> <!-自动扫描 mapping.xml 文件-> <property name = "mapperlocations"value = "comppath.wine/dao/* mapper.wine/dao/ <spath.配置 log4j-> <속성 이름 = "configlocation"value = "classpath : mybatis-config.xml"> </property> </bean>
are : 아이디어 idea 출력 中 中, 如果需要筛选, 快捷键 ctrl+f
【拓展】
“:”控制 : log4j 打印出 mybatis 中仅仅单个 맵퍼 的配置。
<!-4 log4j2 <仅仅打印出单个 맵퍼 的 sql 语句的配置-> <logger name = "com.beebank.dao.iface.usermapper"> <level> 디버그 </level> </logger>
以上就是本文的全部内容 以上就是本文的全部内容, 希望对大家的学习有所帮助, 也希望大家多多支持武林网。