title: How to configure Log4j with IntelliJ and Gradle
body: <p>I must be doing something stupid, but I can't find it. I'm trying to add Log4j to my project, but it isn't reading the properties file. I have created a minimal workable example project. In IntelliJ, I created a new gradle project. I added log4j and added a main class.</p>
  <p>Here is the project structure.</p>
  <pre><code>.
  ├── build.gradle
  ├── gradle
  │   └── wrapper
  │       ├── gradle-wrapper.jar
  │       └── gradle-wrapper.properties
  ├── gradlew
  ├── gradlew.bat
  ├── settings.gradle
  └── src
      ├── main
      │   ├── java
      │   │   └── Main.java
      │   └── resources
      │       └── log4j.properties
      └── test
          ├── java
          └── resources
  </code></pre>
  <p>build.gradle</p>
  <pre><code>plugins {
      id 'java'
  }
  
  group 'org.example'
  version '1.0-SNAPSHOT'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.3'
  }
  </code></pre>
  <p>log4j.properties</p>
  <pre><code>log4j.rootLogger=TRACE
  </code></pre>
  <p>Main.java</p>
  <pre><code>import org.apache.logging.log4j.LogManager;
  
  public class Main {
      public static void main(String[] args) {
          System.out.println(&quot;Print&quot;);
          System.out.println(&quot;Root Logger Level: &quot; + LogManager.getRootLogger().getLevel());
      }
  }
  </code></pre>
  <p>When I run this, the output says that the root logger's level is &quot;ERROR&quot;, even though I'm setting it to trace. Of course this means that any log statements below error level are not printed.</p>
  <pre><code>Print
  Root Logger Level: ERROR
  </code></pre>
  <p>Every piece of documentation I read says that the properties file needs to be in a directory on the classpath, which makes sense. According to the gradle documentation and my own investigation, the resources directory is on the classpath. Experimentally, I have tried placing the file at every level of the hierarchy with no difference. I can't see any reason why the properties file isn't being found.</p>
  <p>I tried specifying it directly by adding <code>-Dlog4j.configuration=&lt;full/path/to/properties&gt;</code> to the VM arguments. This still didn't work, but gradle gives me the following output:</p>
  <pre><code>BUILD SUCCESSFUL in 748ms
  3 actionable tasks: 1 executed, 2 up-to-date
  ERROR StatusLogger Reconfiguration failed: No configuration found for '2a139a55' at 'null' in 'null'
  10:23:30 PM: Task execution finished 'Main.main()'.
  </code></pre>
  <p>This appears to happen after the program has terminated. I'm not sure if it's related.</p>
  <p>I <em>must</em> be missing something stupid, but I can't find anything. I've looked at dozens of examples and it seems like I'm doing everything right. What am I missing?</p>