Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3215

Gradle instructions for adding log4j as a dependency are outdated

    XMLWordPrintableJSON

Details

    • Documentation
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.17.2
    • None
    • None

    Description

      I believe the instructions, are not up-to-date. The "directive" compile has been deprecated in favor of implementation see here and here.

      I've tried setting up a hello-world Java application using Gradle and during gradle build I've got the following error:

      ...
      > Could not find method compile() for arguments [{group=org.apache.logging.log4j, name=log4j-api, version=2.15.0}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
      ...
      

      To test this locally I've set up a Dockerfile that showcases using both compile and implementation. Download the attached Dockerfile into a folder and can build the Docker container locally:

       # DOCKER_BUILDKIT=1 is necessary because I use new Docker HEREDOC feature, see comments
       # in Dockerfile
      $ DOCKER_BUILDKIT=1 docker build --tag log4j-docs .
      

      Once built, run this to see the usage proposed by current docs:

      $ docker run -it log4j-docs ./use-compile.sh
      

      Which fails. Then try the new version that succeeds:

      $ docker run -it log4j-docs ./use-implementation.sh
      

      See the Dockerfile for details.

      Disclaimer:
      I'm not a Javist and haven't been using Log4j nor Gradle, please, review carefully. This could be a simple docs change, but I don't know if older Gradle versions that could still use compile are still more adapted and therefore this documentation might not work for them. Maybe the docs could specify multiple Gradle build instructions? I am not the one to decide, just laying it out here.

      Also, my first issue on Apache, let me know if there is something I should improve upon.

      Duplicates
      The following search yielded 0 hits.

      Attachments

        1. Dockerfile-1
          2 kB
          quapka

        Activity

          People

            vy Volkan Yazici
            quapka quapka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: