4

When using Log4j2 in Intellij for a groovy/gradle project, log shows up red as if the injection is not working. Gradle runs and builds but every file in IntelliJ shows errors which is annoying.

dependencies

compile 'org.codehaus.groovy:groovy-all:2.4.4'
compile 'org.apache.logging.log4j:log4j-api:2.5'
compile 'org.apache.logging.log4j:log4j-core:2.5'

Source

import groovy.util.logging.Log4j2
@Log4j2
class TestLog4j2 {
    public static void log(String message) {
        log.error(message)

log from log.error is displayed in red and displays error, cannot resolve symbol 'log' The log4j2.xml file is in the classpath and works. @Log4j and even @Slf4j both work Using IntelliJ 15.03 Build IU-143.1821 Project is using Groovy 2.4.4 and Gradle 2.3

Thoughts anyone?

Dave Brunkow
  • 352
  • 6
  • 20

1 Answers1

0

I was getting this error when using groovy's @Log4j2 annotation.

The solution was to exclude the following module in gradle:

configurations.all {
  exclude module: 'log4j-to-slf4j'
}
smac89
  • 39,374
  • 15
  • 132
  • 179