如何在Embedded Glassfish中获取Server.log

时间:2010-11-23 11:15:32

标签: glassfish-3 glassfish-embedded

我正在使用Embedded Glassfish与Arquillian进行一些In-Container-Tests。现在,当我的测试失败时,我总是从那些混杂着Arquillian特定内容的测试中获得堆栈跟踪。但关于失败测试的真正原因是什么的信息很少。 使用常规Glassfish,我可以检查server.log以获取更多信息。不幸的是,Embedded Glassfish似乎没有提供Server.log。 我还查看了由Arquillian / Embedded Glassfish创建的临时目录,但它不包含任何日志文件。

如何在Embedded Glassfish中激活日志记录?

顺便说一下,我的pom中有以下依赖项:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-glassfish-embedded-3</artifactId>
        <version>1.0.0.Alpha4</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>3.1-b06</version>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-testng</artifactId>
        <version>1.0.0.Alpha4</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId> 
        <artifactId>testng</artifactId> 
        <version>5.13.1</version> 
        <scope>test</scope> 
    </dependency> 
</dependencies>

1 个答案:

答案 0 :(得分:5)

使用arquillian,testng和嵌入式glassfish时遇到完全相同的问题我遇到了很多困难。几个小时后,我设法让它工作

我发现arquillian依赖于使用slf4j-api的slf4j-simple版本1.5.9.RC1。

为了让它正常工作,我添加了属性

<properties>
   <version.slf4j>1.5.9.RC1</version.slf4j>
</properties>

和依赖项

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>${version.slf4j}</version>
</dependency> 

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
</dependency>

然后在依赖管理下

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${version.slf4j}</version>
        </dependency> 
    </dependencies>
</dependencyManagement>  

一旦我有了这个,我将我常用的log4j.properties文件添加到src / test / resources中,一切正常。

干杯

相关问题