简体   繁体   中英

log4j settings in Apache Calcite project

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?

  1. please modify the example/csv/build.gradle.kts,

add follow lines to dependencies:

   testRuntimeOnly("org.slf4j:slf4j-log4j12")

2.then copy the core\\src\\test\\resource\\log4j.properties to example\\src\\test\\resource\\log4j.properties

add follow lines:


# Increase level to DEBUG for RelOptPlanner
log4j.logger.org.apache.calcite.plan.RelOptPlanner=TRACE
# Increase level to TRACE for HepPlanner
log4j.logger.org.apache.calcite.plan.hep.HepPlanner=TRACE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM