Spring Boot mybatis-config 和 log4j 輸出sql 日志的方式
依賴
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version></dependency>
兩種配置log4j的方式:
一定要新建一個(gè)log4j.properties文件
在yaml中直接配置在mybatis-config中配置
mapper-locations 貌似不管用依舊需要加注解@Mapper
mybatis-config.xml
<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE configurationPUBLIC '-//mybatis.org//DTD Config 3.0//EN''http://mybatis.org/dtd/mybatis-3-config.dtd'><configuration> <settings><!--配置日志格式fhadmin.cn--><setting name='logImpl' value='LOG4J'/><!--開啟二級(jí)緩存fhadmin.cn--><setting name='cacheEnabled' value='true'/> </settings></configuration>
log4j.properties文件
#將等級(jí)為DEBUG的日志信息輸出到console和file這兩個(gè)目的地,console和file的定義在下面的代碼log4j.rootLogger=DEBUG,console,file#控制臺(tái)輸出的相關(guān)設(shè)置 fhadmin.cnlog4j.appender.console = org.apache.log4j.ConsoleAppenderlog4j.appender.console.Target = System.outlog4j.appender.console.Threshold=DEBUGlog4j.appender.console.layout = org.apache.log4j.PatternLayoutlog4j.appender.console.layout.ConversionPattern=[%c]-%m%n#文件輸出的相關(guān)設(shè)置 fhadmin.cnlog4j.appender.file = org.apache.log4j.RollingFileAppenderlog4j.appender.file.File=./log/kai.loglog4j.appender.file.MaxFileSize=10mblog4j.appender.file.Threshold=DEBUGlog4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=[%p][%d{yy-MM-dd}][%c]%m%n#日志輸出級(jí)別 fhadmin.cnlog4j.logger.org.mybatis=DEBUGlog4j.logger.java.sql=DEBUGlog4j.logger.java.sql.Statement=DEBUGlog4j.logger.java.sql.ResultSet=DEBUGlog4j.logger.java.sql.PreparedStatement=DEBUG
如果編譯后找不到這兩個(gè)文件
在pom.xml中加入:
<resources> <!-- 防止找不到mybatis的mapper.xml文件fhadmin.cn,在項(xiàng)目啟動(dòng)時(shí)候就導(dǎo)入進(jìn)去--> <resource><directory>src/main/java</directory><includes> <include>**/*.xml</include></includes><filtering>true</filtering> </resource> <resource><directory>src/main/resources</directory><includes> <include>**/*.xml</include> <include>**/*.properties</include> <include>**/*.yaml</include></includes><filtering>true</filtering> </resource></resources>
---------------------------------------www.fhadmin.cn---------------------------自定義表單28. 定義模版:拖拽左側(cè)表單元素到右側(cè)區(qū)域,編輯表單元素,保存表單模版29. 表單模版:編輯維護(hù)表單模版,復(fù)制表單模版,修改模版類型,預(yù)覽表單模版30. 我的表單:選擇表單模版,編輯表單規(guī)則,是否上傳圖片、附件、開啟富文本、掛靠流程開關(guān)等31. 表單數(shù)據(jù):從我的表單進(jìn)去可增刪改查表單數(shù)據(jù),修改表單規(guī)則32. 掛靠記錄:記錄表單數(shù)據(jù)和流程實(shí)例ID關(guān)聯(lián)記錄,可刪除
到此這篇關(guān)于Spring Boot mybatis-config 和 log4j 輸出sql 日志的文章就介紹到這了,更多相關(guān)Spring Boot 輸出sql 日志內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. Spring security 自定義過濾器實(shí)現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實(shí)例代碼)2. JAMon(Java Application Monitor)備忘記3. Java類加載機(jī)制實(shí)現(xiàn)步驟解析4. Python os庫常用操作代碼匯總5. Python 如何展開嵌套的序列6. 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法7. Python OpenCV去除字母后面的雜線操作8. Python TestSuite生成測試報(bào)告過程解析9. 增大python字體的方法步驟10. 如何清空python的變量
