Skip to content
Advertisement

Adding log4j to build.gradle

Trying to create simple Gradle Java project in my Eclipse. I’m using LOG4J library, so my build.gradle looks:

JavaScript


I added two lines in this file that I expect will allow to download log4j library:

JavaScript

But looks this not help, because in case I build project with gradle I have compile errors.

JavaScript

I suppose I declared log4j in deprecated way (I took these lines from log4j manual). But how to declare log4j in build.gradle in order to use them in my project?

Build command:

JavaScript

And my main class:

JavaScript

Advertisement

Answer

I suppose I declared log4j in deprecated way (I took these lines from log4j manual).

Just because the manual/documentation says to do it one way doesn’t necessarily mean it is accurate or correct. The documentation was likely written at the time where the compile configuration was not deprecated. With the the introduction of the implementation and api configurations, there is no need for the compile configuration.

Simply switch compile to implementation and the deprecation warning will go away.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement