【问题标题】:Problem with ANT output, java logging and SPRING tutorialANT 输出、java 日志记录和 SPRING 教程的问题
【发布时间】:2010-12-07 11:49:21
【问题描述】:

我目前正在按照本教程学习SPRING:http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html

一切正常,但 Ant 输出总是显示“标准错误”和正常的日志记录内容,我认为这是错误的。

$ ant tests
Buildfile: build.xml

build:

buildtests:

    [javac] Compiling 1 source file to /Users/Shared/Projects/springapp/war/WEB-INF/classes

tests:

    [junit] Running springapp.web.HelloWorldControllerTests
    [junit] Oct 30, 2007 11:31:43 PM springapp.web.HelloController handleRequest
    [junit] INFO: Returning hello view
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.03 sec
    [junit] Testsuite: springapp.web.HelloWorldControllerTests
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.03 sec
    [junit] ------------- Standard Error -----------------
    [junit] Oct 30, 2007 11:31:43 PM springapp.web.HelloController handleRequest
    [junit] INFO: Returning hello view
    [junit] ------------- ---------------- ---------------

BUILD SUCCESSFUL
Total time: 2 seconds

如何改变这种行为?日志输出不是错误,还是针对 Ant?感谢您的任何想法和澄清!

【问题讨论】:

    标签: java spring logging ant


    【解决方案1】:

    查看链接教程,“junit”任务如下所示。

    将其更改为showoutput="false" 以隐藏测试输出。我猜教程打开了它,这样你就可以看到发生了什么,但通常它是隐含的“假”——如果你省略了“showoutput”属性,这是默认值。

    <junit printsummary="on"
        fork="false"
        haltonfailure="false"
        failureproperty="tests.failed"
        showoutput="true">
        <classpath refid="master-classpath"/>
        <formatter type="brief" usefile="false"/>
    
        <batchtest>
            <fileset dir="${build.dir}">
                <include name="**/*Tests.*"/>
            </fileset>
        </batchtest>
    
    </junit>
    

    【讨论】:

    • 这会改变输出,从而不再显示第一条 INFO 消息。我怎样才能摆脱 STANDARD ERROR 部分中的 INFO 消息。这不是错误,只是一些日志记录...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 2021-03-15
    相关资源
    最近更新 更多