How does log4j2 output sql statements executed by hibernate?

problem description

A SSH project that used to use log4j to manage logs needs to be upgraded to log4j2, but has been unable to output sql statements executed by hibernate to the log file.

the environmental background of the problems and what methods you have tried

the project uses the SSH framework
now uses the configuration of hibernate < prop key= "hibernate.show_sql" > true < / prop > you can output sql statements to the console
the configuration was found on the Internet but is not valid

<!-- sql -->
<Logger name="org.hibernate.SQL" level="debug" additivity="false">
    <AppenderRef ref="console" />
</Logger>

<!-- sql -->
<Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="trace" additivity="false">
    <AppenderRef ref="console" />
</Logger>

related codes

log4j2 profile

<?xml version="1.0" encoding="UTF-8"?>
<!-- log4j2  -->
<!--  trace<debug<info<warn<error<fatal -->
<configuration status="debug">
    <!--  -->
    <Properties>
        <!--  -->
        <Property name="pattern">%d{yyyy-MM-dd HH:mm:ss,SSS} (%F:%L) %5p %m%n</Property>
        <!--  -->
        <Property name="filePath">D:/Tomcat 6.0/log4j/demo/</Property>
        <!-- debug -->
        <Property name="debugFileName">${filePath}/debug.log</Property>
        <!-- info -->
        <Property name="infoFileName">${filePath}/info.log</Property>
        <!-- error -->
        <Property name="errorFileName">${filePath}/error.log</Property>
    </Properties>
    
    <!--  -->
    <appenders>
        <!--  -->
        <Console name="console" target="SYSTEM_OUT">
            <!--  -->
            <PatternLayout pattern="${pattern}"/>
        </Console>
        
        <!-- debug -->
        <RollingFile name="debug_appender" fileName="${debugFileName}"
                filePattern="${filePath}/%d{yyyy-MM-dd}/debug_%i.log">
            <!--  -->
            <Filters>
                <!-- debuginfo -->
                <ThresholdFilter level="debug"/>
                <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
            </Filters>
            <!--  -->
            <PatternLayout pattern="${pattern}"/>
            <!--  -->
            <Policies>
                <!--  -->
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
                <!--  -->
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
        </RollingFile>
        
        <!-- info -->
        <RollingFile name="info_appender" fileName="${infoFileName}"
                filePattern="${filePath}/%d{yyyy-MM-dd}/info_%i.log">
            <!--  -->
            <Filters>
                <!-- infoerror -->
                <ThresholdFilter level="info"/>
                <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
            </Filters>
            <!--  -->
            <PatternLayout pattern="${pattern}"/>
            <!--  -->
            <Policies>
                <!--  -->
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
                <!--  -->
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
        </RollingFile>
        
        <!-- error -->
        <RollingFile name="error_appender" fileName="${errorFileName}"
                filePattern="${filePath}/%d{yyyy-MM-dd}/error_%i.log">
            <!--  -->
            <Filters>
                <!-- error -->
                <ThresholdFilter level="error"/>
            </Filters>
            <!--  -->
            <PatternLayout pattern="${pattern}"/>
            <Policies>
                <!--  -->
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
                <!--  -->
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
        </RollingFile>
    </appenders>
    
    <!-- logger -->
    <loggers>
        
        <!-- logger -->
        <!-- debug appender -->
        <Root level="debug">
            <!--  -->
            <AppenderRef ref="console"/>
            <!-- debug -->
            <AppenderRef ref="debug_appender"/>
            <!-- info -->
            <AppenderRef ref="info_appender"/>
            <!-- error -->
            <AppenderRef ref="error_appender"/>
        </Root>
    </loggers>
</configuration>
May.13,2021

try adding this configuration:

spring.jpa.show-sql=true
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be6b54-317fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be6b54-317fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?