这里以logback为例。

其实只需要在logback.xml中增加下面一行配置就而已了。

1
<logger name="mapper所在的包名" level="DEBUG"></logger>

下面贴一个完整的logback的配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<configuration>
    <!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d %p (%file:%line\)- %m%n</pattern>
            <charset>GBK</charset>
        </encoder>
    </appender>	
    <appender name="baselog"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>log/base.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>log/base.log.%d.%i</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!-- or whenever the file size reaches 64 MB -->
                <maxFileSize>64 MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>
                %d %p (%file:%line\)- %m%n
            </pattern>
            <charset>UTF-8</charset>
            <!-- 此处设置字符集 -->
        </encoder>
    </appender>
    <root level="info">
        <appender-ref ref="STDOUT"/>
    </root>
    <logger name="com.ybf" level="DEBUG">
        <appender-ref ref="baselog"/>
    </logger>
    <logger name="com.ybf.activity.web.mapper" level="DEBUG">
        <appender-ref ref="STDOUT" />
    </logger>
</configuration>

注:测试的spring boot版本为1.5.4.RELEASE.