apache / logging-log4j2 Goto Github PK
View Code? Open in Web Editor NEWApache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
Home Page: https://logging.apache.org/log4j/2.x/
License: Apache License 2.0
Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
Home Page: https://logging.apache.org/log4j/2.x/
License: Apache License 2.0
Currently RewriteAppender
does not override requiresLocation
from AbstractAppender
making RewriteAppender::requiresLocation
always return false
. This results in the location not being passed to its underlying appenders when needed.
Instead, RewriteAppender::requiresLocation
should return true when any of its appenders requires a location.
Starting log4j2-2.18.0 the following configuration:
Configuration:
status: warn
Appenders:
Console:
- name: STDOUT
target: SYSTEM_OUT
PatternLayout:
Pattern: "%style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{disableAnsi=false}"
Throws an exception:
2023-01-13 12:45:47,690 main WARN The style attribute disableAnsi=false is incorrect. java.lang.IllegalArgumentException: No enum constant org.apache.logging.log4j.core.pattern.AnsiEscape.DISABLEANSI=FALSE
at java.base/java.lang.Enum.valueOf(Enum.java:274)
at org.apache.logging.log4j.util.EnglishEnums.valueOf(EnglishEnums.java:67)
at org.apache.logging.log4j.util.EnglishEnums.valueOf(EnglishEnums.java:50)
at org.apache.logging.log4j.core.pattern.AnsiEscape.createSequence(AnsiEscape.java:486)
at org.apache.logging.log4j.core.pattern.StyleConverter.newInstance(StyleConverter.java:96)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.apache.logging.log4j.core.pattern.PatternParser.createConverter(PatternParser.java:590)
at org.apache.logging.log4j.core.pattern.PatternParser.finalizeConverter(PatternParser.java:657)
at org.apache.logging.log4j.core.pattern.PatternParser.parse(PatternParser.java:420)
at org.apache.logging.log4j.core.pattern.PatternParser.parse(PatternParser.java:177)
at org.apache.logging.log4j.core.layout.PatternLayout$SerializerBuilder.build(PatternLayout.java:473)
at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:139)
at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:60)
at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:766)
at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:626)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:124)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1133)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1058)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1050)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1050)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:659)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:257)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:303)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
at com.bol.logging.log4j2.config.DisableAnsiSpec.$spock_feature_0_0(DisableAnsiSpec.groovy:24)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:187)
at org.spockframework.runtime.model.MethodInfo.lambda$new$0(MethodInfo.java:49)
at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at org.spockframework.runtime.PlatformSpecRunner.invokeRaw(PlatformSpecRunner.java:407)
at org.spockframework.runtime.PlatformSpecRunner.invoke(PlatformSpecRunner.java:390)
at org.spockframework.runtime.PlatformSpecRunner.runFeatureMethod(PlatformSpecRunner.java:324)
at org.spockframework.runtime.IterationNode.execute(IterationNode.java:50)
at org.spockframework.runtime.SimpleFeatureNode.execute(SimpleFeatureNode.java:58)
at org.spockframework.runtime.SimpleFeatureNode.execute(SimpleFeatureNode.java:15)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.spockframework.runtime.SpockNode.sneakyInvoke(SpockNode.java:40)
at org.spockframework.runtime.IterationNode.lambda$around$0(IterationNode.java:67)
at org.spockframework.runtime.PlatformSpecRunner.lambda$createMethodInfoForDoRunIteration$5(PlatformSpecRunner.java:236)
at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at org.spockframework.runtime.PlatformSpecRunner.invokeRaw(PlatformSpecRunner.java:407)
at org.spockframework.runtime.PlatformSpecRunner.invoke(PlatformSpecRunner.java:390)
at org.spockframework.runtime.PlatformSpecRunner.runIteration(PlatformSpecRunner.java:218)
at org.spockframework.runtime.IterationNode.around(IterationNode.java:67)
at org.spockframework.runtime.SimpleFeatureNode.lambda$around$0(SimpleFeatureNode.java:52)
at org.spockframework.runtime.SpockNode.sneakyInvoke(SpockNode.java:40)
at org.spockframework.runtime.FeatureNode.lambda$around$0(FeatureNode.java:41)
at org.spockframework.runtime.PlatformSpecRunner.lambda$createMethodInfoForDoRunFeature$4(PlatformSpecRunner.java:199)
at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at org.spockframework.runtime.PlatformSpecRunner.invokeRaw(PlatformSpecRunner.java:407)
at org.spockframework.runtime.PlatformSpecRunner.invoke(PlatformSpecRunner.java:390)
at org.spockframework.runtime.PlatformSpecRunner.runFeature(PlatformSpecRunner.java:192)
at org.spockframework.runtime.FeatureNode.around(FeatureNode.java:41)
at org.spockframework.runtime.SimpleFeatureNode.around(SimpleFeatureNode.java:52)
at org.spockframework.runtime.SimpleFeatureNode.around(SimpleFeatureNode.java:15)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.spockframework.runtime.SpockNode.sneakyInvoke(SpockNode.java:40)
at org.spockframework.runtime.SpecNode.lambda$around$0(SpecNode.java:63)
at org.spockframework.runtime.PlatformSpecRunner.lambda$createMethodInfoForDoRunSpec$0(PlatformSpecRunner.java:61)
at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at org.spockframework.runtime.PlatformSpecRunner.invokeRaw(PlatformSpecRunner.java:407)
at org.spockframework.runtime.PlatformSpecRunner.invoke(PlatformSpecRunner.java:390)
at org.spockframework.runtime.PlatformSpecRunner.runSpec(PlatformSpecRunner.java:55)
at org.spockframework.runtime.SpecNode.around(SpecNode.java:63)
at org.spockframework.runtime.SpecNode.around(SpecNode.java:11)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Not sure where to report this, so I'm reporting it here.
The link at this page is dead:
https://logging.apache.org/log4j/2.x/log4j-iostreams.html
In this sentence: "For more information, see [Runtime Dependencies](https://logging.apache.org/log4j/runtime-dependencies.html).
"
The link provided leads to a 404 page.
I use the log4j in the springBoot and i add the artifactId "log4j-spring-boot" for enable the use the springboot properties in the log4j.xml.
When i use inside the File, it's work very well, but when i try use in the File header, the log4j send the error.
In summary, below i pasted the code, but when i try use the ${spring:log4j.solver.service.path}, the system throw the error (log)
Version: 2.19.0
Operating system: Windows 10
JDK: Java 17 (Adoptium)
application.properties file:
log4j.solver.service.name=${LOG4J_SOLVER_SERVICE_NAME:solver-service}
log4j.solver.service.version=${LOG4J_SOLVER_SERVICE_VERSION:1}
log4j.solver.service.enviroment=${LOG4J_SOLVER_SERVICE_ENVIROMENT:dev}
log4j.solver.service.path=${LOG4J_SOLVER_SERVICE_PATH:solver-service.log}`
LOG4J.XML file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="solver-service" fileName="${spring:log4j.solver.service.path}" append="false">
<EcsLayout serviceName="${spring:log4j.solver.service.name}" serviceVersion="${spring:log4j.solver.service.version}" serviceEnvironment="${spring:log4j.solver.service.enviroment}"/>
</File>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%level - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="propagate-logger" level="INFO" additivity="false">
<AppenderRef ref="solver-service"/>
</Logger>
<Root level="INFO">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
Connected to the target VM, address: '127.0.0.1:52527', transport: 'socket'
2023-02-06 09:38:15,994 main ERROR FileManager (${spring:log4j.solver.service.path}) java.io.IOException: A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta java.io.IOException: A sintaxe do nome do arquivo, do nome do diretório ou do rótulo do volume está incorreta
at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:462)
at java.base/java.io.File.getCanonicalPath(File.java:626)
at java.base/java.io.File.getCanonicalFile(File.java:651)
at org.apache.logging.log4j.core.util.FileUtils.makeParentDirs(FileUtils.java:139)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:436)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:423)
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:144)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:183)
[application.properties.txt](https://github.com/apache/logging-log4j2/files/10663203/application.properties.txt)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:99)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:124)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1138)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1063)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1055)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:664)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:258)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:304)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:621)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:694)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.commons.logging.LogAdapter$Log4jLog.<clinit>(LogAdapter.java:155)
at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog(LogAdapter.java:122)
at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:89)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:179)
at net.weg.solverservice.SolverServiceApplication.main(SolverServiceApplication.java:18)
2023-02-06 09:38:15,997 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory@2b95e48b] unable to create manager for [${spring:log4j.solver.service.path}] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData@4a3329b9] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory@2b95e48b] unable to create manager for [${spring:log4j.solver.service.path}] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData@4a3329b9]
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:146)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:183)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:99)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:124)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1138)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1063)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1055)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:664)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:258)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:304)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:621)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:694)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.commons.logging.LogAdapter$Log4jLog.<clinit>(LogAdapter.java:155)
at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog(LogAdapter.java:122)
at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:89)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:179)
at net.weg.solverservice.SolverServiceApplication.main(SolverServiceApplication.java:18)
2023-02-06 09:38:15,998 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:260)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:136)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1138)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1063)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1055)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:664)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:258)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:304)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:621)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:694)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.commons.logging.LogAdapter$Log4jLog.<clinit>(LogAdapter.java:155)
at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog(LogAdapter.java:122)
at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:89)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:179)
at net.weg.solverservice.SolverServiceApplication.main(SolverServiceApplication.java:18)
2023-02-06 09:38:16,003 main ERROR Null object returned for File in Appenders.
2023-02-06 09:38:16,008 main ERROR Unable to locate appender "solver-service" for logger config "propagate-logger"
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.3)
INFO - HV000001: Hibernate Validator 6.2.4.Final
INFO - Starting SolverServiceApplication using Java 17.0.4.1 on BRJGSD357212 with PID 73264 (C:\Projetos\solver-service\target\classes started by schotten in C:\Projetos\solver-service)
INFO - The following 1 profile is active: "dev"
INFO - Multiple Spring Data modules found, entering strict repository configuration mode
INFO - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
INFO - Finished Spring Data repository scanning in 16 ms. Found 0 JPA repository interfaces.
INFO - Tomcat initialized with port(s): 8010 (http)
INFO - Initializing ProtocolHandler ["http-nio-8010"]
Configure the springboot app and use the Log4j.xml and applicatio.proprerties informed in this message and reproduce the error.
Log4j2 has a couple of remaining call sites of String#toLowerCase
and String#toUpperCase
, which are locale-dependent. These calls should be replaced with Strings#toRootLowerCase
and Strings#toRootUpperCase
.
Such a call is present for example in PluginManager
, which causes IfLastModified
to be transformed to ıflastmodified
(with a dotless i), if the locale is Turkish (cf. this SO question).
The "Tag library reference" disappeared after version 2.17.1, while the "TLDDoc documentation" disappeared after version 2.17.2:
https://logging.apache.org/log4j/2.x/log4j-taglib/index.html
I was getting some ReusableMessageFactoryTest
failures in the release-2.x branch (without any modifications). It seemed that another test (TraceLoggingTest) was leaving an unreleased ReusableParameterizedMessage
in the ReusableMessageFactory
thread local. This only seems to be happening in my new dev environment (Azure VM) and is test order specific.
In the DefaultFlowMessageFactory#newEntryMessage()
, entry ReusableMessages were being converted to immutable Messages and failing to release the original ReusableMessage.
In contrast, in DefaultFlowMessageFactory#newExitMessage()
, ReusableMessages were being used directly (without being made immutable). I'm not sure if this was an oversight, but I decided to make both methods call into makeImmutable().
This issue would leave ReusableMessages reuse in a useless state after entry/exit logging was used by a thread.
Version: release-2.x
Operating system: Azure Linux VM
JDK: JDK8
[ERROR] Failures:
[ERROR] ReusableMessageFactoryTest.testCreateEventOverwritesFields:81->assertReusableParameterizeMessage:58 reserved ==> expected: <true> but was: <false>
[ERROR] ReusableMessageFactoryTest.testCreateEventReturnsSameInstance:47 expected: <ReusableParameterizedMessage[messagePattern=null, stringArgs=[1, 2, 3, 4], throwable=null]> but was: <ReusableParameterizedMessage[messagePattern=text, p0={} p1={} p2={} p3={}, stringArgs=[9, 8, 7, 6], throwable=null]>
[INFO]
[ERROR] Tests run: 683, Failures: 2, Errors: 0, Skipped: 2
I'm not sure how to influence the order in which Maven runs tests. I added a test to TraceLoggingTest that shows that the thread local Message used is not being released.
// Ensure that ReusableParameterizedMessages are getting released correctly
@Test
public void testReusableMessageHandling() throws InstantiationException, IllegalAccessException {
assertSame(AbstractLogger.DEFAULT_MESSAGE_FACTORY_CLASS, ReusableMessageFactory.class,
"The default message factory has changed");
final MessageFactory factory = new ReusableMessageFactory();
final Message reusedMessage = factory.newMessage("test {}", null);
ReusableMessageFactory.release(reusedMessage);
traceEntry("Entry test {}", 0);
assertReusedMessage(reusedMessage, factory);
traceExit("Exit test {}", 0);
assertReusedMessage(reusedMessage, factory);
}
private void assertReusedMessage(Message reusableMessage, MessageFactory factory) {
final Message testMessage = factory.newMessage("test {}", 0);
assertSame(reusableMessage, testMessage);
ReusableMessageFactory.release(testMessage);
}
The CONTRIBUTING.md
file needs some updates. E.g. the requirement for "minimal updates" needs to be more precise: Spotless might require reformatting entire files.
We have an Eclipse RCP application where we use Log4J 2 (with SLF4J 1.7.36) to do all the logging. Logging using the following dependencies works fine:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.19.0</version>
</dependency>
But.. when we update the dependencies to 2.20.0, we get a log list of exceptions. I think I have tracked down the difference in behavior to the ServiceLoaderUtil class:
...
if (OsgiServiceLocator.isAvailable()) {
services = Stream.concat(services, OsgiServiceLocator.loadServices(serviceType, lookup, verbose));
}
...
In 2.19.0 the OsgiServiceLocator.isAvailable() returns false, but with 2.20.0 it returns true and executes the row below the check. Here the exceptions are logged in the try/catch clauses.
Version: 2.20.0
Operating system: Windows Enterprise 10.0.19044
JDK: JDK 17.0.6.10.1
...
____________________________
Welcome to Apache Felix Gogo
g! ERROR StatusLogger Unable to load OSGI services for service class org.apache.logging.log4j.spi.Provider
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.BundleContext.getServiceReferences(java.lang.Class, String)" because "ctx" is null
at org.apache.logging.log4j.util.OsgiServiceLocator.loadServices(OsgiServiceLocator.java:61)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:92)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:77)
at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
at org.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:99)
at org.apache.logging.log4j.ThreadContext.init(ThreadContext.java:223)
at org.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:201)
at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:87)
at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:71)
at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:189)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:86)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:105)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:135)
at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:32)
at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:74)
at org.apache.logging.log4j.core.selector.BasicContextSelector.<clinit>(BasicContextSelector.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:230)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOfProperty(Loader.java:338)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:100)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:61)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:78)
at com.bordsdam.cs.logging.LoggingHandler.init(LoggingHandler.java:281)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:86)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:64)
at com.bordsdam.cs.ma3.client.frabbjuice.Activator.<clinit>(Activator.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:801)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:753)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
at org.eclipse.osgi.container.Module.doStart(Module.java:605)
at org.eclipse.osgi.container.Module.start(Module.java:468)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:89)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:230)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:229)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
ERROR StatusLogger Unable to load OSGI services for service interface org.apache.logging.log4j.core.util.ContextDataProvider
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.BundleContext.getServiceReferences(java.lang.Class, String)" because "ctx" is null
at org.apache.logging.log4j.util.OsgiServiceLocator.loadServices(OsgiServiceLocator.java:61)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:92)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:77)
at org.apache.logging.log4j.core.impl.ThreadContextDataInjector.getServiceProviders(ThreadContextDataInjector.java:77)
at org.apache.logging.log4j.core.impl.ThreadContextDataInjector.<clinit>(ThreadContextDataInjector.java:64)
at org.apache.logging.log4j.core.impl.ThreadContextDataInjector$ForDefaultThreadContextMap.<init>(ThreadContextDataInjector.java:93)
at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:91)
at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:71)
at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:189)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:86)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:105)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:135)
at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:32)
at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:74)
at org.apache.logging.log4j.core.selector.BasicContextSelector.<clinit>(BasicContextSelector.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:230)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOfProperty(Loader.java:338)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:100)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:61)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:78)
at com.bordsdam.cs.logging.LoggingHandler.init(LoggingHandler.java:281)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:86)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:64)
at com.bordsdam.cs.ma3.client.frabbjuice.Activator.<clinit>(Activator.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:801)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:753)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
at org.eclipse.osgi.container.Module.doStart(Module.java:605)
at org.eclipse.osgi.container.Module.start(Module.java:468)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:89)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:230)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:229)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
ERROR StatusLogger Unable to load OSGI services for service interface org.apache.logging.log4j.core.util.WatchEventService
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.BundleContext.getServiceReferences(java.lang.Class, String)" because "ctx" is null
at org.apache.logging.log4j.util.OsgiServiceLocator.loadServices(OsgiServiceLocator.java:61)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:92)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:77)
at org.apache.logging.log4j.core.util.WatchManager.<init>(WatchManager.java:137)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:142)
at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:32)
at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:74)
at org.apache.logging.log4j.core.selector.BasicContextSelector.<clinit>(BasicContextSelector.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:230)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOfProperty(Loader.java:338)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:100)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:61)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:78)
at com.bordsdam.cs.logging.LoggingHandler.init(LoggingHandler.java:281)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:86)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:64)
at com.bordsdam.cs.ma3.client.frabbjuice.Activator.<clinit>(Activator.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:801)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:753)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
at org.eclipse.osgi.container.Module.doStart(Module.java:605)
at org.eclipse.osgi.container.Module.start(Module.java:468)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:89)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:230)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:229)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
ERROR StatusLogger Unable to load OSGI services for service interface org.apache.logging.log4j.core.util.WatchEventService
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.BundleContext.getServiceReferences(java.lang.Class, String)" because "ctx" is null
at org.apache.logging.log4j.util.OsgiServiceLocator.loadServices(OsgiServiceLocator.java:61)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:92)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:77)
at org.apache.logging.log4j.core.util.WatchManager.<init>(WatchManager.java:137)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:142)
at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:46)
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:84)
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:99)
at org.apache.logging.log4j.core.selector.BasicContextSelector.<clinit>(BasicContextSelector.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:230)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOfProperty(Loader.java:338)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:100)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:61)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:165)
at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:186)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:206)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:78)
at com.bordsdam.cs.logging.LoggingHandler.init(LoggingHandler.java:281)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:86)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:64)
at com.bordsdam.cs.ma3.client.frabbjuice.Activator.<clinit>(Activator.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:801)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:753)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
at org.eclipse.osgi.container.Module.doStart(Module.java:605)
at org.eclipse.osgi.container.Module.start(Module.java:468)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:89)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:230)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:229)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
ERROR StatusLogger Unable to load OSGI services for service interface org.apache.logging.log4j.core.util.WatchEventService
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.BundleContext.getServiceReferences(java.lang.Class, String)" because "ctx" is null
at org.apache.logging.log4j.util.OsgiServiceLocator.loadServices(OsgiServiceLocator.java:61)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:92)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:77)
at org.apache.logging.log4j.core.util.WatchManager.<init>(WatchManager.java:137)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:142)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:78)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:533)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:457)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:318)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:690)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:245)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
at com.bordsdam.cs.logging.LoggingHandler.init(LoggingHandler.java:281)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:86)
at com.bordsdam.cs.logging.LoggingHandler.createLogger(LoggingHandler.java:64)
at com.bordsdam.cs.ma3.client.frabbjuice.Activator.<clinit>(Activator.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:801)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:753)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
at org.eclipse.osgi.container.Module.doStart(Module.java:605)
at org.eclipse.osgi.container.Module.start(Module.java:468)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:89)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:230)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:229)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
...
(log continues normally as with 2.19.0)
The JeroMqAppenderTest
timeouts every other CI run on Windows.
This might be a problem with the runner's resources (TCP port), some race condition in the test, but it can be also a problem in the JeroMqAppender
.
Hello, so I want to get the value of fileName as a String from an appender. But when I use the Log4j 2 API, it loads the log4j.xml and creates files with the value inside of "fileName". I understand why it works that way but I want to ask if there is a way to read the log4j.xml, get the value of "fileName" as a String from the appender without loading it and creating files, that done with Log4j2 API. Because I have running server at the same time using that log4j.xml and I don't want the API loading it at the same time. So I am interested in that if the API can just read the xml file something like parser.
Thank you for your answer in advance!!!
I use PosixViewAttribute to set file permission
<DefaultRolloverStrategy max="4">
<PosixViewAttribute basePath="${LOG_HOME}" filePermissions="r--------">
<IfFileName glob="*.gz" />
</PosixViewAttribute>
</DefaultRolloverStrategy>
When I start my project in Windows (like in Intellij IDEA), I got the following error info.
main ERROR Null object returned for PosixViewAttribute in DefaultRolloverStrategy
Though it seems that log still functions properly, how can I make the error info disappear?
BTW: I do know taht PosixViewAttribute should only work on Linux, but I want to keep the configuartion to be same in both the Windows and Linux.
JMX is an older API from Java for recording various metrics and publishing them along with other remote management features. It seems as though the JDK Flight Recorder API would be more appropriate to use in 3.x, though in the meantime, it would be nice to make JMX usage opt-in as it increases the time for a cold app start and is otherwise less commonly used these days thanks to things like JFR.
If disabling JMX entirely seems too drastic, then the JMX functionality that exists in Log4j should be broken up into more fine-grained feature flags to allow for selective use of it.
Warning!
It is highly recommended to discuss feature requests in the mailing lists first.
I'm talking on behalf of Google and the OpenSSF.
There is a known issue of github workflow that it grants write permission to all workflows unless defined otherwise, thus, it is both a recommendation from OpenSSF Scorecard and the Github to always use credentials that are minimally scoped.
I've seen that almost all of logging-log4h2 workflows already has the permissions minimally scoped, except for codeql that, although it has the permissions set at the job, it has no top level permission defined. Just to guarantee that no job eventually added to the workflow will have undesirable write permissions, I'll send a suggestion setting the top level permission as none.
Feel free to reach me out in case of any doubts or concerns.
I use the Apache Tomcat.
We have configured the log4j2 Java Options Arguments: -Dlog4j.configurationFile={/path1}/log4j2.xml,{/path2}/log4j2.xml.
The two files are related one for Web Application and the other for WebServices (so the JDK is the same), on startup the logs collected are:
ll wss_*
-rw-r----- 1 root mf 0 1 feb 12.55 wss_alarms.log
-rw-r----- 1 root mf 5368 1 feb 12.55 wss_axis.log
-rw-r----- 1 root mf 1082 1 feb 12.55 wss_database.log
-rw-r----- 1 root mf 123172 1 feb 13.12 wss_main.log
-rw-r----- 1 root mf 0 1 feb 12.55 wss_warrants.log
-rw-r----- 1 root mf 0 1 feb 12.55 wss_wfa.log
ll webapp_*
-rw-r----- 1 root mf 8172 1 feb 13.13 webapp_actions.log
-rw-r----- 1 root mf 176 1 feb 12.55 webapp_database.log
-rw-r----- 1 root mf 0 1 feb 12.55 webapp_grids.log
-rw-r----- 1 root mf 0 1 feb 12.55 webapp_json.log
-rw-r----- 1 root mf 4796 1 feb 12.55 webapp_struts.log
I use the DefaultRolloverStrategy max="5", with the number of retention days, below is an example:
<RollingFile name="RollingAlarms" fileName="${log-path-wss}/${service-suffix-wss}_alarms.log" append="true" filePattern="${log-path-wss}/${service-suffix-wss}_alarms-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="%d %5p (%F:%L) %m%n" />
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB" />
<CronTriggeringPolicy schedule="0 0 0 * * ?" />
</Policies>
<DefaultRolloverStrategy max="${retention-days-wss}">
<Delete basePath="${log-path-wss}" maxDepth="1">
<IfFileName glob="${service-suffix-wss}_alarms-*.log" />
<IfLastModified age="${retention-days-wss}d" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
The problem is that in after the file rolling, no more log are produced and the rotated file stays at zero length:
-rw-r--r-- 1 root mf 92521 31 gen 23.59 wss_wfa-2023-01-31-1.log
-rw-r--r-- 1 root mf 0 1 feb 00.00 wss_wfa.log
Operating system:
Application server:
Log4j2 Version:
JDK:
No logs
Configure tomcat with two different log4j2.xml file and different attributes, when log4j start rolling, the lines log not add in the new file and no more log are produced.
It seems that this example is not quite correct on line 28?
Hybrid Example
There is no XMLConfiguration class but only an XmlConfiguration class.
Additionally the method createLogger is deprecated.
And the variable "refs" is also not defined anywhere
Maybe you should write a new example for the hybrid application.
But maybe I understand the API wrong.
When I have an instance of a java.sql.Date
object and try to log it as a parameterized message, the newest version of Log4J assumes it's a regular java.util.Date
one and tries to call Date.toInstant()
when logging it. This works for java.util.Date
and its subclasses java.sql.Timestamp
and java.sql.Time
(which uses a specific format for that type), but fails for java.sql.Date
, as it throws an UnsupportedOperationException
.
Version: 2.20.0
ERROR StatusConsoleListener An exception occurred processing Appender Console
java.lang.UnsupportedOperationException
at java.sql/java.sql.Date.toInstant(Date.java:316)
at org.apache.logging.log4j.message.ParameterFormatter.appendDate(ParameterFormatter.java:492)
at org.apache.logging.log4j.message.ParameterFormatter.appendSpecialTypes(ParameterFormatter.java:485)
at org.apache.logging.log4j.message.ParameterFormatter.recursiveDeepToString(ParameterFormatter.java:474)
at org.apache.logging.log4j.message.ParameterFormatter.recursiveDeepToString(ParameterFormatter.java:449)
at org.apache.logging.log4j.message.ParameterFormatter.formatMessage2(ParameterFormatter.java:192)
at org.apache.logging.log4j.message.ParameterizedMessage.formatTo(ParameterizedMessage.java:227)
at (...)
at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1407)
at com.example.Log4JTest.test(Log4JTest.java:13)
at (...)
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="%d{MM-dd HH:mm:ss.SSS} %5p %c: %m%n%ex"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
JUnit test:
public class Log4JTest {
@Test
void test() {
Logger logger = LogManager.getLogger();
logger.info("Test: {}", java.sql.Date.valueOf(LocalDate.now()));
}
}
Certain accessor patterns in master
has diverged from release-2.x
and gravitated from setters to withers. As discussed in the mailing list, it is better use setters everywhere in the code base.
As reported in this StackOverflow question if the configuration does not contain all required properties, at least the IfLastModified
fails with a NullPointerException
instead of a proper error message.
We should probably check all components in org.apache.logging.log4j.core.appender.rolling
for similar issues.
While looking for eligible files, AbstractRolloverStrategy makes unnecessary IO access if logfilePattern
doesn't match PATTERN_COUNTER
. File parent
is never used in such case:
protected SortedMap<Integer, Path> getEligibleFiles(final String currentFile, final String path,
final String logfilePattern, final boolean isAscending) {
final TreeMap<Integer, Path> eligibleFiles = new TreeMap<>();
final File file = new File(path);
File parent = file.getParentFile();
if (parent == null) {
parent = new File(".");
} else {
parent.mkdirs();
}
if (!PATTERN_COUNTER.matcher(logfilePattern).matches()) {
return eligibleFiles;
}
The check can be skipped by moving the pattern matching to the beginning of the function:
protected SortedMap<Integer, Path> getEligibleFiles(final String currentFile, final String path,
final String logfilePattern, final boolean isAscending) {
final TreeMap<Integer, Path> eligibleFiles = new TreeMap<>();
if (!PATTERN_COUNTER.matcher(logfilePattern).matches()) {
return eligibleFiles;
}
Beyond being a little bit more efficient, it also prevents creation of empty dirs, if they no longer exist.
The fix for LOG4J2-3647 didn't include an equivalent fix for our SLF4J binding. An SLF4J call:
logger.atDebug()...
discards all messages less specific than DEBUG
, even those messages that would be accepted by a global filter.
The equivalent Logback issue is LOGBACK-1719.
This issue was reported in this StackOverflow question.
StackTraceStringResolver
contains the following lines:
@Override
public void resolve(
final Throwable throwable,
final JsonWriter jsonWriter) {
final TruncatingBufferedPrintWriter srcWriter = srcWriterRecycler.acquire();
try {
throwable.printStackTrace(srcWriter);
final TruncatingBufferedPrintWriter dstWriter = truncate(srcWriter);
jsonWriter.writeString(dstWriter);
} finally {
srcWriterRecycler.release(srcWriter);
}
}
private TruncatingBufferedPrintWriter truncate(
final TruncatingBufferedPrintWriter srcWriter) {
// ...
// Allocate temporary buffers and truncate the input.
final TruncatingBufferedPrintWriter dstWriter =
dstWriterRecycler.acquire();
try {
// ...
} finally {
dstWriterRecycler.release(dstWriter);
}
return dstWriter;
}
dstWriter
created in truncate()
recycled there, though used in resolve()
later on.
When pushing changes to CI spotless runs and tries to rewrite the Apache License (especially it lowercases license
from Apache License
-- I don't personally care about two spaces after a period...)
Specifically, consider:
https://github.com/apache/logging-log4j2/blob/c173bfe8f0e0446efde4060d6b16c29625e0ca6c/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/internal/format/FastDateParserSDFTest.java
commit c173bfe8f0e0446efde4060d6b16c29625e0ca6c
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/internal/format/FastDateParserSDFTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/internal/format/FastDateParserSDFTest.java
index ad3450268..d7a7ab53c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/internal/format/FastDateParserSDFTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/internal/format/FastDateParserSDFTest.java
@@ -2,7 +2,7 @@
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
@@ -13,4 +13,4 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
Version: [Log4j version]
Operating system: [OS and version]
ubuntu-latest
JDK: [JDK distribution and version]
Spotless is configured to enforce this license here:
https://github.com/apache/logging-log4j2/blob/main/pom.xml#L1606
And the license content apparently comes from here:
https://github.com/apache/logging-log4j2/blob/main/checkstyle-header.txt
So the fix would be to correct the license content.
I have ~50 logs from spotless and a bunch of them force these changes (e.g. https://github.com/check-spelling/logging-log4j2/actions/runs/4300307860/jobs/7496386113). I also have a run where spotless stopped yelling once I applied these changes.
Touch a file that has an apache license and trigger spotless via CI
I am trying to build and test on ppc64le(ubi). However the API tests fail on running the ./mvnw
verify command. I've installed jdk 8, 9 and 11 and added it to toolchains.cml file.
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] ServiceLoaderUtilTest.testBrokenServiceFile:88 expected: <2> but was: <1>
[INFO]
[ERROR] Tests run: 681, Failures: 1, Errors: 0, Skipped: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache Log4j 2 2.19.1-SNAPSHOT:
[INFO]
[INFO] Apache Log4j 2 ..................................... SUCCESS [ 2.476 s]
[INFO] Apache Log4j API Java 9 support .................... SUCCESS [ 3.274 s]
[INFO] Apache Log4j API ................................... SUCCESS [ 1.749 s]
[INFO] Apache Log4j Implementation Java 9 support ......... SUCCESS [ 0.446 s]
[INFO] Apache Log4j Core .................................. SUCCESS [ 1.799 s]
[INFO] Apache Log4j API Tests ............................. FAILURE [ 16.645 s]
[INFO] Apache Log4j Core Tests ............................ SKIPPED
[INFO] Apache Log4j 1.x Compatibility API ................. SKIPPED
[INFO] Apache Log4j App Server Support .................... SKIPPED
[INFO] Apache Log4j BOM ................................... SKIPPED
[INFO] Apache Log4j to SLF4J Adapter ...................... SKIPPED
[INFO] Apache Log4j SLF4J Binding ......................... SKIPPED
[INFO] Apache Log4j Cassandra ............................. SKIPPED
[INFO] Apache Log4j Core Integration Tests ................ SKIPPED
[INFO] Apache Log4j CouchDB ............................... SKIPPED
[INFO] Apache Log4j Docker Library ........................ SKIPPED
[INFO] Apache Log4j Commons Logging Bridge ................ SKIPPED
[INFO] Apache Log4j Flume Bridge .......................... SKIPPED
[INFO] Apache Log4j Streaming Interface ................... SKIPPED
[INFO] Apache Log4j Jakarta SMTP .......................... SKIPPED
[INFO] Apache Log4j Jakarta Web ........................... SKIPPED
[INFO] Apache Log4j JPA ................................... SKIPPED
[INFO] Apache Log4j JDK Platform Logging Adapter .......... SKIPPED
[INFO] Apache Log4j JDBC DBCP 2 ........................... SKIPPED
[INFO] Apache Log4j JMX GUI ............................... SKIPPED
[INFO] Apache Log4j JUL Adapter ........................... SKIPPED
[INFO] Apache Log4j Kubernetes Library .................... SKIPPED
[INFO] Apache Log4j Layout for JSON template .............. SKIPPED
[INFO] Apache Log4j Layout for JSON template Tests ........ SKIPPED
[INFO] Apache Log4j Liquibase Binding ..................... SKIPPED
[INFO] Apache Log4j MongoDB 3 ............................. SKIPPED
[INFO] Apache Log4j MongoDB 4 ............................. SKIPPED
[INFO] Apache Log4j to JUL Bridge ......................... SKIPPED
[INFO] Apache Log4j OSGi .................................. SKIPPED
[INFO] Apache Log4J Performance Tests ..................... SKIPPED
[INFO] Apache Log4j Samples ............................... SKIPPED
[INFO] Apache Log4j Samples: Flume - Common ............... SKIPPED
[INFO] Apache Log4j Samples: Flume - Remote ............... SKIPPED
[INFO] Apache Log4j Samples: Flume - Embedded ............. SKIPPED
[INFO] Apache Log4j Samples: Configuration ................ SKIPPED
[INFO] Apache Log4j Samples: LoggerProperties ............. SKIPPED
[INFO] Apache Log4j SLF4J 2.0 Binding ..................... SKIPPED
[INFO] Apache Log4j Spring Boot Support ................... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Support ........... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Client Support .... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Samples ........... SKIPPED
[INFO] Apache Log4j Sample Configuration Service .......... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Sample Application SKIPPED
[INFO] Apache Log4j Web ................................... SKIPPED
[INFO] Apache Log4j Tag Library ........................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.831 s
[INFO] Finished at: 2023-01-31T05:06:57Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M7:test (default-test) on project log4j-api-test: There are test failures.
[ERROR]
[ERROR] Please refer to /logging-log4j2/log4j-api-test/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :log4j-api-test`
I have a custom Appender and want to configure a specific ContextDataProvider for this Appender, how can I do it? After reading the documentation and code, I found that ContextDataProvider is loaded through SPI, which means that once I load it through SPI, it will work for all Appenders, but I only want a certain Appender to take effect.
I tried specifying a ContextDataProvider in the config file:
<LogCollector name="MyAppender">
<ContextDataProvider class="com.xxx.MyContextDataProvider"/>
<PatternLayout pattern="${CONSOLE_LOG_PATTERN}" charset="UTF-8"/>
</LogCollector>
Then I got an error:
ERROR StatusConsoleListener MyAppender contains an invalid element or attribute "ContextDataProvider"
what should I do?
The version of log4j I am using is v2.20
Using log4j2.properties to define AsyncAppender and have RFA added to the AsyncAppender. Somehow the appender ref is not correctly getting identified and hence it's resulting in error.
Version: 2.17.2
Operating system: MacOS 13.2
JDK: 1.8.0_341
log4j2.properties:
appender.DRFA.type = RollingFile
appender.DRFA.name = DRFA
appender.DRFA.fileName = xyz
appender.DRFA.filePattern = xyz
appender.DRFA.createOnDemand = true
appender.DRFA.layout.type = PatternLayout
appender.DRFA.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n
appender.DRFA.policies.type = Policies
appender.DRFA.policies.time.type = TimeBasedTriggeringPolicy
appender.DRFA.policies.time.interval = 1
appender.DRFA.policies.time.modulate = true
appender.DRFA.policies.size.type = SizeBasedTriggeringPolicy
appender.DRFA.policies.size.size = 256MB
appender.DRFA.strategy.type = DefaultRolloverStrategy
appender.DRFA.strategy.max = 20
appender.ASYA.type = Async
appender.ASYA.name = ASYA
appender.ASYA.appenderRefs = DRFA
appender.ASYA.blocking = true
appender.ASYA.bufferSize = 256
This results in error:
2023-01-26 00:58:07,944 main ERROR No appender references provided to AsyncAppender: appenderRefs
2023-01-26 00:58:07,951 main DEBUG AsyncAppender$Builder(={}, errorRef="null", blocking="true", shutdownTimeout="null", bufferSize="256", name="ASYA", includeLocation="null", Configuration(PropertiesConfig), ignoreExceptions="null", BlockingQueueFactory=null, Filter=null, ={})
2023-01-26 00:58:07,951 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.AsyncAppender for element Async org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element Async are invalid: field 'appenderRefs' has invalid value '[Lorg.apache.logging.log4j.core.config.AppenderRef;@35cabb2a'
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:212)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1122)
...
...
...
Tried these options but they are not able to attach ref:
appender.ASYA.appenderRefs.ref = DRFA
appender.ASYA.appenderRefs.DRFA.ref = DRFA
appender.ASYA = DRFA
escapeSDParams()
called by appendMap()
matches PARAM_VALUE_ESCAPE_PATTERN
expressions against MDC data. This can be improved by a manual comparison.
Version 2.20 was released four days days ago, and documentation gives Maven coordinates for version 2.20. However the newest version available on Maven central repository is still 2.19.
Version: 2.20
Check available version for log4j on Maven Central Repository.
The log4j-core test-jar for 2.20.0 does not appear to be published to Maven Central.
Version: 2.20.0
Operating system: n/a
JDK: n/a
Could not find artifact org.apache.logging.log4j:log4j-core:jar:tests:2.20.0 in central (https://repo.maven.apache.org/maven2), try downloading from https://logging.apache.org/log4j/2.x/download.html -> [Help 1]
Add the following dependency into pom.xml and see it fail to download:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
<type>test-jar</type>
</dependency>
Given the desire for a minimal core module, we won't have XML support by default. To address this, we should either convert the core XML tests to JSON files, or we'll need to depend on optional modules in our tests here which is less clean.
Considering the need for linking java.management
to even load JMX, this should be separated into its own module.
As discussed in the mailing list, we better enforce signed commits in the repository. This better be reflected in a GitHub Pull Request template along with some other checks:
Hello basically i am using log4j library and this support minSdk 26 and currently i am using minSdk 21 but the problem is i cannot upgrade minSdk version to 26 .
So is there any way to compatible midSdk 21 to 26 .. Any help would be appreciated
We have a legacy class that loads Log4J using PropertyConfigurator.configure(Properties) via the bridge libraries. Since 2.17.2, once this line is hit our Log4j2 statements will stop logging. I have been able to replicate through 2.20. Changing between 2.17.1 and 2.17.2 in the attached Maven project will replicate the before and after scenarios.
Version: 2.17.2
Operating system: Windows Server 2012
JDK: 1.8 - 11
Project attached
Log4J2Issue.zip
Fault injection: VM file handles are used up, and logs cannot be printed after the fault is rectified. IOException: Stream Closed.
[A clear and concise description of what the bug is.]
Version: [Log4j version]
2.71.1
Operating system: [OS and version]
linux
JDK: [JDK distribution and version]
openjdk 1.8
Logs during fault injection:
Logs After Fault Recovery:
[Stacktraces, errors, etc. relevant applications logs.]
[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]
org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager#writeToDestination
randomAccessFile should check whether The Stream is closed。
I am using log4j-to-slf4j to forward all log4j calls to slf4j for my library LogCaptor. At August 2022 slf4j maintainers released version 2 which does not work anymore with log4j-to-slf4j
. Would it be possible to make it compatible again?
A workaround for me would be forwarding log4j calls to jul and use that, but that I would not be able to use MDC for example and that is the reason why I am hoping that log4j-to-slf4j could be compatible with the latest slf4j release.
[A clear and concise description of what the bug is.]
Non log calls are being sent to slf4j (tested with v2.0.6) from log4j (tested with v2.19.0)
Version: 2.19.0
Operating system: any
JDK: oracle jdk 1.8
[Stacktraces, errors, etc. relevant applications logs.]
Git fork and clone: https://github.com/Hakky54/log-captor
Adjust the slf4j version to 2.0.6 and run the test with mvn verify
Dozens of modules are failing on javadoc:javadoc
goal. Causes need to be fixed and javadoc:javadoc
should be attached to the verify
phase.
It is not possible to use custom logger appender without explicitly specifying appender's package in log4j2.xml
.
Version: 2.20.0
Operating system: Windows 10
, Ubuntu 20.04.5 LTS
JDK: openjdk 17.0.6 2023-01-17 LTS
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
ERROR StatusConsoleListener Appenders contains an invalid element or attribute "MyAppender"
ERROR StatusConsoleListener Unable to locate appender "myAppender" for logger config "root"
Project structure |
---|
|
📄 |
---|
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo.log4j2</groupId>
<artifactId>log4j2-demo</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>demo.log4j2.MyAppender</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
</dependency>
</dependencies>
</project> |
📄 |
---|
package demo.log4j2;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Core;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
@Plugin(name = "MyAppender", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE)
public class MyAppender extends AbstractAppender {
private static final Logger LOGGER = LoggerFactory.getLogger(MyAppender.class);
protected MyAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
}
@PluginFactory
public static MyAppender createAppender(@PluginAttribute("name") String name, @PluginElement("Filter") Filter filter) {
return new MyAppender(name, filter, PatternLayout.createDefaultLayout(), true, Property.EMPTY_ARRAY);
}
public static void main(String[] args) {
LOGGER.info("Hello world!");
}
@Override
public void append(LogEvent event) {
System.out.println(event.getMessage().getFormattedMessage());
}
} |
📄 |
---|
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Appenders>
<MyAppender name="myAppender"/>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="myAppender"/>
</Root>
</Loggers>
</Configuration> |
C:\Users\Yevhen\.jdks\corretto-17.0.6\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.2\lib\idea_rt.jar=50945:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Yevhen\IdeaProjects\log4j2-demo\target\classes;C:\Users\Yevhen\.m2\repository\org\slf4j\slf4j-api\2.0.7\slf4j-api-2.0.7.jar;C:\Users\Yevhen\.m2\repository\org\apache\logging\log4j\log4j-slf4j2-impl\2.20.0\log4j-slf4j2-impl-2.20.0.jar;C:\Users\Yevhen\.m2\repository\org\apache\logging\log4j\log4j-api\2.20.0\log4j-api-2.20.0.jar;C:\Users\Yevhen\.m2\repository\org\apache\logging\log4j\log4j-core\2.20.0\log4j-core-2.20.0.jar demo.log4j2.MyAppender
Hello world!
Process finished with exit code 0
mvn clean package
C:\Users\Yevhen\IdeaProjects\log4j2-demo\target>java -jar log4j2-demo-1.0.0-jar-with-dependencies.jar
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
ERROR StatusConsoleListener Appenders contains an invalid element or attribute "MyAppender"
ERROR StatusConsoleListener Unable to locate appender "myAppender" for logger config "root"
log4j2.xml
and replace:
<Configuration status="warn">
<Configuration status="warn" packages="demo.log4j2">
C:\Users\Yevhen\IdeaProjects\log4j2-demo\target>java -jar log4j2-demo-1.0.0-jar-with-dependencies.jar
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
Hello world!
According to this article MyAppender
must be autoconfigured at build time:
Serialized plugin listing files are generated by an annotation processor contained in the log4j-core artifact which
will automatically scan your code for Log4j 2 plugins and output a metadata file in your processed classes. There is
nothing extra that needs to be done to enable this; the Java compiler will automatically pick up the annotation
processor on the class path unless you explicitly disable it.
Even if I add this plugin to pom.xml
, nothing will be changed:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>log4j-plugin-processor</id>
<goals>
<goal>compile</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<proc>only</proc>
<annotationProcessors>
<annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
</annotationProcessor>
</annotationProcessors>
</configuration>
</execution>
</executions>
</plugin>
In order to determine which message format syntax to use in FormattedMessage
, this uses a regular expression. This can be simplified by flipping the ordering to check for a parametrized message first before assuming it's a printf-style message.
Hey,
It appears that a recent changed forced a change of the Javadoc URL from https://logging.apache.org/log4j/2.x/log4j-api/apidocs/ to https://logging.apache.org/log4j/2.x/javadoc/log4j-api/index.html.
Is there a particular reason why this was changed without a redirect pointing to the new location? This change affects hundreds of files in open source projects, now left behind broken.
Some builds may also fail because a build tool can no longer obtain the file from the old location:
Error fetching URL: https://logging.apache.org/log4j/2.x/log4j-api/apidocs/ (java.io.FileNotFoundException: https://logging.apache.org/log4j/2.x/log4j-api/apidocs/package-list)
Why do you need both identifiers and names? Is one of them not enough to identify the appender at logger definition?
for example: appender.console.name = STDOUT
I know my english is terrible, but this is the most incomprehensible documentation I have ever read:
https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties
It is full of ambiguous statements. Brain surgery is easier to learn than log4j documentation. It has more information than in the Bible. It is not easy to use at all compared to version 1, what worked really well! Unnecessarily overcomplicated.
currently our logging framework is implemented with 1.2.17 log4j jar. we have got vulnerability from security team to use latest version 2.x of Log4j but current version doesn't have Log4jLoggingNode jar.
[A clear and concise description of what the bug is.]
Version: [Log4j version]
1.2.17
Operating system: [OS and version]
Redhat Linux
JDK: [JDK distribution and version]
[Stacktraces, errors, etc. relevant applications logs.]
[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]
I was using 2,17.0 with log4j-1.2-api 2.17.0 to read my external log4j.properties file and everything went well. But since those deserialization issues appeared last year, I have updated them to 2.19.0, then I noticed my log file stopped rotating daily and keep everything in one since the update. I tried to restart the jvm and nothing change, so I think it might be the log4j's issue.
Version: 2.19.0
Operating system: Win server 2019
JDK: openjdk version "1.8.0_171-1-redhat"
While logger methods with Supplier<?>
in the signature are the easiest way to log lazily, we should also detect when users pass suppliers as Object
parameters. It would be nice if:
log.info("The {} {} {} jumps over the {}.", brown, quick, fox, (Supplier<?>) () -> "lazy dog");
gave the same result as:
log.info("The {} {} {} jumps over the {}.", () -> brown, () -> quick, () ->fox, () -> "lazy dog");
This proble appears in a StackOverflow question, but probably in many more.
It's no way to create MongoDb4Provider
programmatically. Setter for connectionStringSource
is missing in Builder.
Version: 2.14.0+ (From the first version when MongoDB 4 support was added)
https://github.com/check-spelling/logging-log4j2/actions/runs/4309470335/jobs/7516899702#step:5:363
[INFO] Minimal buildinfo generated from downloaded artifacts: /home/runner/work/logging-log4j2/logging-log4j2/log4j-api/target/reference/log4j-api-3.0.0-SNAPSHOT.buildinfo
Error: sha512 mismatch log4j-api-3.0.0-SNAPSHOT.jar: investigate with diffoscope log4j-api/target/reference/log4j-api-3.0.0-SNAPSHOT.jar log4j-api/target/log4j-api-3.0.0-SNAPSHOT.jar
Error: Reproducible Build output summary: 3 files ok, 1 different
Error: see diff log4j-api/target/reference/log4j-api-3.0.0-SNAPSHOT.buildinfo log4j-api/target/log4j-api-3.0.0-SNAPSHOT.buildinfo
Error: see also https://maven.apache.org/guides/mini/guide-reproducible-builds.html
[INFO] Reproducible Build output comparison saved to /home/runner/work/logging-log4j2/logging-log4j2/log4j-api/target/log4j-api-3.0.0-SNAPSHOT.buildcompare
[INFO] Aggregate buildcompare copied to /home/runner/work/logging-log4j2/logging-log4j2/target/log4j-3.0.0-SNAPSHOT.buildcompare
This failure should trigger an actions/upload-artifact
step that uploads all the relevant files so that contributors (especially drive-by) can see the things that it doesn't like.
When I implemented the StrLookup in my Lookup then in runtime classpath couldn't find StrLookup inteface. My guess is that it's due to reflection, the interface is available at compile time but couldn't include in build so it's unavailable at runtime.
Version: 2.3 | 2.17.2 | 2.19.0
Operating system: Android 11
JDK: Embedded JDK Version 11.0.15
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/logging/log4j/core/lookup/StrLookup;
at com.example.application.local_log.AndroidLog4jHelper.initialise(AndroidLog4jHelper.java:36)
at com.example.application.my_app.app.MainApplication.setupLog4J(MainApplication.java:329)
at com.example.application.my_app.app.MainApplication.onCreate(MainApplication.java:323)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7593)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2177)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.logging.log4j.core.lookup.StrLookup" on path: DexPathList[[zip file "/data/app/~~xPUZykkWQAbNPadqT4Iamw==/com.example.application.my_app-q2_T3J_MHK2KX_sdSlYhjw==/base.apk"],nativeLibraryDirectories=[/data/app/~~xPUZykkWQAbNPadqT4Iamw==/com.example.application.my_app-q2_T3J_MHK2KX_sdSlYhjw==/lib/arm64, /data/app/~~xPUZykkWQAbNPadqT4Iamw==/com.example.application.my_app-q2_T3J_MHK2KX_sdSlYhjw==/base.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.dpdtech.application.local_log.AndroidLog4jHelper.initialise(AndroidLog4jHelper.java:36)
at com.example.application.my_app.app.MainApplication.setupLog4J(MainApplication.java:329)
at com.example.application.my_app.app.MainApplication.onCreate(MainApplication.java:323)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7593)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2177)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
you can reproduce it just pull this code and run it (https://github.com/roman-mityukov/log4j2-android)
When spotless fails, all of the files it wants to change and the diffs it produces should be uploaded as artifacts using actions/upload-artifact
so that contributors (especially drive-by) can see the things that it doesn't like and apply them directly without having to go through 50 iterations to get to a satisfactory state.
Hello,
I would like to request that certain APIs which are currently protected be exposed as public for broader access. Specifically, I am interested in accessing createCompressAction()
, getExtension()
, length()
in FileExtension
enum for customized rollover strategy which we have written at our end.
Could you please consider this request and let me know if it is possible to make these APIs public? I would be happy to provide more information or answer any questions you may have.
Thank you for your time and consideration.
Best regards,
Karthi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.