GitHub user jbisotti edited a comment on the discussion: 
java.lang.IllegalArgumentException: The `GraalVmProcessor` annotation processor 
is missing the required `log4j.graalvm.groupId` and `log4j.graalvm.artifactId` 
options

Apologies; I misspoke yesterday.

We recently added a unit test to verify the contents of a log message, 
including the context keys/values. I likely missed something but I couldn't 
find an easy way to do that. I ended up borrowing `ListAppender` from 
`log4j-core-test` so our test code did in fact contain an `@Plugin`. I've now 
removed this and added `log4j-core-test` as a `test` dependency.

Also, we intentionally had `log4j-core` as a `compile` dependency because the 
code includes a few CLI utilities and on of them was using 
`Configurator.initialize(...)`. I've now removed this and changed it to a 
`runtime` dependency.

With the the two changes above, and not doing anything special to deal with the 
GraalVM annotation processor issue, my code now compiles cleanly and the tests 
run successfully.

That said, adding the `log4j-core-test` dependency was not as clean as one 
would hope. It has a lot of undesirable transitive dependencies (Maven? 
Spring?). Literally, all I needed was `ListAppender`.
```xml
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core-test</artifactId>
            <version>${log4j.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    
<groupId>com.google.code.java-allocation-instrumentor</groupId>
                    <artifactId>java-allocation-instrumentor</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.assertj</groupId>
                    <artifactId>assertj-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.awaitility</groupId>
                    <artifactId>awaitility</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-commons</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-test</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-model</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit-pioneer</groupId>
                    <artifactId>junit-pioneer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mockito</groupId>
                    <artifactId>mockito-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
```

Like I said, I likely missed something; however, it would be great if there 
were some small/simple artifact with minimal dependencies with the aim of 
making unit testing logging easier. Unit testing logging likely isn't an ideal 
thing to do in general but sometimes it's necessary.

Thanks!

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3755#discussioncomment-13782241

----
This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org

Reply via email to