Checkstyle输出大量调试语句

时间:2017-01-11 14:37:29

标签: java checkstyle

我无法弄清楚造成这种情况的原因。

配置文件似乎没有发生任何变化,虽然必须有所不同,因为它过去不输出这样的东西:

...
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Byte value '0'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value:  
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Character' value ' ' to type 'Character'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a Character
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Double'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Double value '0.0'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Float'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Float value '0.0'
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,889 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Integer'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a Integer
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Long'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Long value '0'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Short'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Short value '0'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0.0
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'BigDecimal' value '0.0' to type 'BigDecimal'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a BigDecimal
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'BigInteger' value '0' to type 'BigInteger'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a BigInteger
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: false
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Boolean' value 'false' to type 'Boolean'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a Boolean
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Byte'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Byte value '0'
11 Jan 2017 15:30:46,890 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value:  
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Character' value ' ' to type 'Character'
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:149)     No conversion required, value is already a Character
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Double'
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Double value '0.0'
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Float'
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:158)     Converted to Float value '0.0'
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:setDefaultValue:336) Setting default value: 0
11 Jan 2017 15:30:46,891 [DEBUG] (AbstractConverter.java:convert:127) Converting 'Integer' value '0' to type 'Integer'
...
谷歌搜索它什么都没有。有些东西肯定已经改变了,但我没有找到什么,或者找出控制这种行为的方法。有人能指出我通常在哪里找到配置吗?

编辑:在查看BeanUtils之后,我发现了一些源代码:https://commons.apache.org/proper/commons-beanutils/apidocs/src-html/org/apache/commons/beanutils/converters/AbstractConverter.html

在其中我找到所有输出语句,包围:

if (log().isDebugEnabled()) {
    log().debug(...
}

显然这回归true。我不明白这是怎么回事。现在我需要找出如何关闭它。

我正在使用Play Framework,它使用了logback。没有log4j属性文件。

编辑:开始对此表示赏心悦目,因为我无法在任何地方找到解决方案,这真令我讨厌。所有谷歌给我的是源代码或其他人的日志。我已经尝试关闭logback配置中的命名空间和类,但这不起作用。我已经尝试将所有内容设置为ERROR和OFF但这也不起作用。我没有想法,而且我无法在任何地方找到解决方案的事实真的很烦人。任何帮助将不胜感激。

编辑:构建工具是play,它是sbt的包装器。 checkstyle的配置如下所示:https://github.com/ymasory/play-pmd-checkstyle/blob/master/project/Build.scala

使用与exameple脚本完全相同的命令行选项。也在Build.scala文件中。

然后你运行play checkstyle并输出它。

checkstyle的配置XML如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
  <property name="severity" value="warning"/>
  <module name="SuppressionFilter">
    <property name="file" value="project/suppressions.xml"/>
  </module>
  <module name="TreeWalker">
    <module name="JavadocMethod">
      <property name="suppressLoadErrors" value="true"/>
    </module>
    <module name="JavadocType"/>
    <module name="JavadocVariable"/>
    <module name="JavadocStyle"/>
    <module name="ConstantName"/>

还有更多模块,直到文件结尾。

2 个答案:

答案 0 :(得分:1)

您应该能够使用log4j.xml文件设置日志级别。如果您看到文档here,您会注意到play框架使用SLF4J作为其默认记录器。这意味着它应该能够以与log4j.properties完全相同的方式进行配置。如果您在这里阅读documentation,那么如果您执行以下操作,则应该能够禁止它:

log4j.rootLogger=ERROR, stdout
<PACKAGE>.checkstyle=WARN

替换您要替换的软件包。例如,如果您要取消java.lang.String,则会替换为java.lang

答案 1 :(得分:0)

如果在Checkstyle中设置-d--debug选项,则会产生JDK日志级别FINEST,而后者将被解释为&#34;启用调试&#34;通过Beanutils。