mybatis‘s log

Charpter 4. Problem

One.Log

stdout

  • I have wasted several hour to find why the sodout do not print the sql statment.During the time of finding ,i have changed several logger type, but the result is uselessful .Suddenly, I am aware of two datasource which maybe lead to this .Through my test,proving this thought is correctly.So ,summary as follow :

    bigger than 1 datasource will lead the stodout's log to bad
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyBatis Plus provides a logging feature that allows you to track and analyze the SQL statements executed by your application. To enable logging in MyBatis Plus, you can configure a logging implementation of your choice, such as Log4j or SLF4J. Here is an example of configuring logging using Log4j: 1. Add the Log4j dependency to your project's build file (e.g., Maven or Gradle). 2. Create a Log4j configuration file (e.g., log4j.properties) and specify the desired logging settings. For example: ```properties # Set root logger level to INFO and appender to console log4j.rootLogger=INFO, console # Define the console appender log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n ``` 3. In your MyBatis Plus configuration file (e.g., mybatis-config.xml), enable logging by adding the following lines: ```xml <configuration> <!-- ... your other configuration settings ... --> <!-- Enable logging --> <settings> <setting name="logImpl" value="LOG4J"/> </settings> </configuration> ``` Make sure to adjust the `value` attribute to match the logging implementation you are using (e.g., `LOG4J2` for Log4j 2.x). With the above configuration, MyBatis Plus will use Log4j for logging. You can then customize the logging settings in your Log4j configuration file as needed. The logged statements will include information such as the executed SQL, parameters, and execution time. Remember to properly configure your logging implementation according to its documentation and your project's needs.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值