Home » Java » java – log4j settings in Apache Calcite project-Exceptionshub

java – log4j settings in Apache Calcite project-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have downloaded the Apache Calcite project and opened its Gradle project in IntelliJ IDEA 2019.3.2. I had a problem that it could not load the slf4j classes correctly (I was getting the SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" error). Finally, I resolved the problem by adding the following lines into build.gradle.kts of the :core module:

dependencies {
  ...   
  implementation("org.slf4j:slf4j-api:1.7.3")
  implementation("org.slf4j:slf4j-simple:1.7.3")
  ...
}

Now get rid of the error; however, the logger is always set to INFO logging level regardless of the core\src\test\resource\log4j.properties setting. Currently, my log4j.properties looks as follows:

# Change rootLogger level to WARN
log4j.rootLogger=ALL, A1

# A1 goes to the console
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p - %m%n

I run the CsvExample tests and no logging occurs. When I debug, I see that the RelOptRuleCall.LOGGER is set to INFO logging level. The RelOptRuleCall.LOGGER is an instance of org.slf4j.impl.SimpleLogger. I was also following the https://calcite.apache.org/docs/howto.html#tracing instructions but without luck (the RelOptRuleCall.LOGGER is set to INFO despite any log4j.properties changes).

I’m using IntelliJ IDEA 2019.3.2 Community edition and Windows 10. I was also trying JDK 1.8 instead of default JDK 11 but with the same result. What am I doing wrong?

How to&Answers: