3

gradle でビルド スクリプトを実行すると、すべてのテスト ケースが正常に動作します。しかし、log4j ロギングも構成しましたが、残念ながらコンソールに表示されません。

log4j.properties :

# Log levels
# Uncomment the following line to enable full loggin for every class
#log4j.rootLogger=trace, stdout, R
log4j.rootLogger=info, stdout, R

# Console appender configuration
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout=org.springframework.boot
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

# Rolling File Appender
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Path and file name to store the log file.
log4j.appender.R.File=./logs/applog.log
log4j.appender.R.MaxFileSize=500KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
# Rolling File Appender layout
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n

build.gradle :

apply plugin: 'java'
apply plugin: 'eclipse'

version = "1.0"
sourceCompatibility = 1.7

jar {
    manifest {
        attributes 'Implementation-Title': 'com.prokarma.automation.sample', 'Implementation-   
        Version': version   
    }
}

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
    }
 }

 repositories { 
     mavenCentral() 
 }  

 sourceSets {
     unitTest {
         java.srcDir file('src/test/java')
         resources.srcDir file('src/test/resources')
     }
 }

 task wrapper(type: Wrapper) {
     description = 'Install Gradle wrapper'
     gradleVersion = '1.10'
 }

 dependencies {

     compile 'org.apache.poi:poi:3.5-beta5'
     compile 'org.testng:testng:6.8.5'
     compile 'log4j:log4j:1.2.17'
     compile 'org.seleniumhq.selenium:selenium-server:2.39.0'
     compile 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.39.0'
     compile 'com.googlecode.json-simple:json-simple:1.1'
     compile 'net.sf.json-lib:json-lib:2.4:jdk15'   
     testRuntime 'log4j:log4j:1.2.17'       
}

test { 
    useTestNG() {  
        options.suites("src/test/resources/testng.xml")
    }
}

uploadArchives {
    repositories {
    flatDir {
           dirs 'repos'
    }
}
}

出力:

[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      clean
[sts]      test
[sts] -----------------------------------------------------
:clean
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources
:testClasses
:test

 BUILD SUCCESSFUL

 Total time: 2.242 secs
 [sts] -----------------------------------------------------
 [sts] Build finished succesfully!
 [sts] Time taken: 0 min, 2 sec
 [sts] -----------------------------------------------------

しかし、log4j ログは表示されません。誰でもこれに対する解決策を教えてもらえますか?

4

1 に答える 1