有:
<logger name="org.hibernate.SQL" level="ERROR">
</logger>
在我的logback.xml上我希望不要将日志视为:
fromLogback 2015-03-17 14:20:56,967 39427 [http-bio-8080-exec-6] DEBUG org.hibernate.SQL - select statsitemi0_.itemId as itemId1_54_, statsitemi0_.companyId as companyI2_54_, statsitemi0_.createDate as
如您所见,首先打印&#34; fromLogback&#34;那是因为我的appender看起来像:
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>fromLogback %d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
但是hibernate调试级别似乎尚未激活,因为我可以看到所有查询。我有属性hibernate.show_sql = false
sessionBuilder.setProperty("hibernate.show_sql",propertiesUtil.getProperty("hibernate.show_sql"));
return sessionBuilder.buildSessionFactory();
只是为了确保在构建会话工厂时打印所有hibernate属性,并且我看到show_sql的值被正确设置为false。
为什么我仍然看到hibernate的调试日志?
更新: 如果我在我的logback.xml上使用,我可以在启动时看到这些日志:
16:06:04,338 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to ERROR
16:06:04,338 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.notnoop.apns.internal.ApnsConnectionImpl] to ERROR
16:06:04,338 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
16:06:04,338 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
16:06:04,338 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
以及之后的一些行:
[http-bio-8080-exec-1] DEBUG org.hibernate.SQL - select propertyim0_.key_ as...
我没有logback-test.xml 我的logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${catalina.base}/logs/liferay.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<!--<appender name="FILE_CACHE" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--<file>${catalina.base}/logs/cache.log</file>-->
<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--<fileNamePattern>${catalina.base}/logs/cache.%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
<!--<!– 30 días de historia –>-->
<!--<maxHistory>30</maxHistory>-->
<!--</rollingPolicy>-->
<!--<encoder>-->
<!--<charset>UTF-8</charset>-->
<!--<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>-->
<!--</encoder>-->
<!--</appender>-->
<appender name="ACCESSLOG" class="ch.qos.logback.core.FileAppender">
<file>${catalina.base}/logs/portlet-shnm-access.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<logger name="com.shn.mkt" level="INFO"/>
<logger name="org.hibernate" level="ERROR"/>
<logger name="com.notnoop.apns.internal.ApnsConnectionImpl" level="ERROR"/>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
<!--<appender-ref ref="ACCESSLOG"/>-->
</root>
</configuration>
请注意,我使用的是Spring Boot,但是对于项目的规范,我现在不能使用application.properties或application.yml,所以我预计使用我自己的logback.xml是够了。
答案 0 :(得分:0)
tomcat的文件setenv.sh有:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=worker,backoffice -Ddebug -Xms128m -Xmx8192m -XX:PermSize=128m -XX:MaxPermSize=256m"
Spring Boot的-Ddebug
是原因......对不起所有噪音。