This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

How do I set up the configuration of slf4j?

You need to add a log4j-test.properties under the directory of java test and then add the following snippets into your build.gradle file.

test {
systemProperty "log4j.configuration", "log4j-test.properties"
}
dependencies {
shadow library.java.slf4j_api
shadow library.java.slf4j_log4j12
// or shadow library.java.slf4j_jdk14
}

Please note that the second dependency shadow library.java.slf4j_log4j12 is not necessary if this dependency is already provided by other library. You can check the dependency tree by launching ./gradlew dependencies to see if it has been included.

If you encounter the error message like this: 

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation

It means that no SLF4J binding is found. So you need to add library.java.slf4j_log4j12 or library.java.slf4j_jdk14 in build.gradle file.


How do I automatically format code and avoid spotless errors?

...

If it is just a simple runner like directRunner, all you need to do is to put your pipeline code under example folder, and then add following build target to the related build.gradle: 

task execute(type:JavaExec) {
main = "org.apache.beam.examples.SideInputWordCount"
classpath = configurations."directRunnerPreCommit"
}


There are also alternative choices, with slight difference:

...