Skip to content

Commit cbdfd1b

Browse files
ppkarwaszvlsi
authored andcommitted
Fix log4j package warning on JMeter startup: WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated ...
The Log4j Core `packages` configuration attribute is deprecated because: * It triggers the scanning of the mentioned packages and slows down the startup process. * It was replaced in version 2.0 by a faster mechanism that relies on a `Log4jPlugins.dat` metadata file. See [Log4j Plugins](https://logging.apache.org/log4j/2.x/manual/plugins.html) for more details. This PR removes the `packages` attribute from the standard configuration file and configures the build script of `jmeter-core` to use the `PluginProcessor` contained in `log4j-core`. See #5937.
1 parent 174ba31 commit cbdfd1b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

bin/log4j2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
~ limitations under the License.
1717
-->
1818

19-
<Configuration status="WARN" packages="org.apache.jmeter.gui.logging">
19+
<Configuration status="WARN">
2020

2121
<Appenders>
2222
<!-- Uncomment to set rotating logs up to 5 files of 100 MB-->

src/core/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.github.autostyle.gradle.AutostyleTask
1919
import com.github.vlsi.gradle.ide.IdeExtension
20+
import java.util.jar.JarFile
2021

2122
plugins {
2223
id("java-test-fixtures")
@@ -45,6 +46,9 @@ dependencies {
4546
api("org.apache.logging.log4j:log4j-core") {
4647
because("GuiLogEventAppender is using log4j-core to implement GUI-based log appender")
4748
}
49+
kapt("org.apache.logging.log4j:log4j-core") {
50+
because("Generates a plugin cache file for GuiLogEventAppender")
51+
}
4852
api("org.apache.logging.log4j:log4j-slf4j-impl") {
4953
because("Both log4j and slf4j are included, so it makes sense to just add log4j->slf4j bridge as well")
5054
}
@@ -188,3 +192,16 @@ tasks.jar {
188192
from("$rootDir/xdocs/images/logo.svg")
189193
}
190194
}
195+
196+
// Checks the generated JAR for a Log4j plugin cache file.
197+
tasks.jar {
198+
doLast {
199+
val jarFile = archiveFile.get().asFile
200+
JarFile(jarFile).use { jar ->
201+
val entryName = "META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat"
202+
if (jar.getJarEntry(entryName) == null) {
203+
throw IllegalStateException("$entryName was not found in $jarFile. The entry should be generated by log4j-core annotation processor")
204+
}
205+
}
206+
}
207+
}

0 commit comments

Comments
 (0)