[jira] [Commented] (LOG4J2-2129) Log4j2 throws NoClassDefFoundError in Java 9
[ https://issues.apache.org/jira/browse/LOG4J2-2129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16402115#comment-16402115 ] Björn Kautler commented on LOG4J2-2129: --- Just in case someone needs a workaround because he cannot update, here is an easy one. Compile a class named {{Log4JModulePatch}} that lies in package {{org.apache.logging.log4j}}. Content of the class: {code} package org.apache.logging.log4j; import org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory; import org.apache.logging.log4j.util.PropertiesUtil; import org.apache.logging.log4j.util.PropertySource; public class Log4JModulePatch { public static void patch() { //TODO: Remove with log4j 2.11.0 or newer Module log4jApiModule = PropertiesUtil.class.getModule(); log4jApiModule.addUses(PropertySource.class); log4jApiModule.addUses(ThreadInfoFactory.class); } } {code} Package it as a JAR and use {{--patch-module org.apache.logging.log4j=path/to/log4j-api-patch.jar}} on execution. You can also simple use the attached [^log4j-api-patch.jar] and use the {{--patch-module}} parameter mentioned above. > Log4j2 throws NoClassDefFoundError in Java 9 > > > Key: LOG4J2-2129 > URL: https://issues.apache.org/jira/browse/LOG4J2-2129 > Project: Log4j 2 > Issue Type: Bug > Components: API >Affects Versions: 2.10.0, 2.11.0 > Environment: Java 9 >Reporter: Blazej >Priority: Major > Fix For: 2.11.0 > > Attachments: log4j-api-patch.jar > > > When I execute a sample project > (https://github.com/bbucko/log4j2-jpms-sample) in Java 9 a following > exception is thrown: > {code} > Exception in thread "main" java.lang.NoClassDefFoundError: Could not > initialize class org.apache.logging.log4j.util.PropertiesUtil > at > org.apache.logging.log4j/org.apache.logging.log4j.status.StatusLogger.(StatusLogger.java:71) > at > org.apache.logging.log4j/org.apache.logging.log4j.LogManager.(LogManager.java:60) > {code} > Exception is a little bit misleading because it seems that true root cause > can be found here: > {code} > java.util.ServiceConfigurationError: > org.apache.logging.log4j.util.PropertySource: module org.apache.logging.log4j > does not declare `uses` > at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588) > at java.base/java.util.ServiceLoader.checkCaller(ServiceLoader.java:574) > at java.base/java.util.ServiceLoader.(ServiceLoader.java:503) > at java.base/java.util.ServiceLoader.load(ServiceLoader.java:1684) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil$Environment.(PropertiesUtil.java:319) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil$Environment.(PropertiesUtil.java:310) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil.(PropertiesUtil.java:69) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil.(PropertiesUtil.java:49) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.Constants.(Constants.java:30) > at java.base/java.lang.Class.forName0(Native Method) > at java.base/java.lang.Class.forName(Class.java:375) > at > org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLogger.createClassForProperty(AbstractLogger.java:198) > at > org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLogger.(AbstractLogger.java:88) > at > org.apache.logging.log4j/org.apache.logging.log4j.LogManager.(LogManager.java:60) > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (LOG4J2-2129) Log4j2 throws NoClassDefFoundError in Java 9
[ https://issues.apache.org/jira/browse/LOG4J2-2129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Björn Kautler updated LOG4J2-2129: -- Attachment: log4j-api-patch.jar > Log4j2 throws NoClassDefFoundError in Java 9 > > > Key: LOG4J2-2129 > URL: https://issues.apache.org/jira/browse/LOG4J2-2129 > Project: Log4j 2 > Issue Type: Bug > Components: API >Affects Versions: 2.10.0, 2.11.0 > Environment: Java 9 >Reporter: Blazej >Priority: Major > Fix For: 2.11.0 > > Attachments: log4j-api-patch.jar > > > When I execute a sample project > (https://github.com/bbucko/log4j2-jpms-sample) in Java 9 a following > exception is thrown: > {code} > Exception in thread "main" java.lang.NoClassDefFoundError: Could not > initialize class org.apache.logging.log4j.util.PropertiesUtil > at > org.apache.logging.log4j/org.apache.logging.log4j.status.StatusLogger.(StatusLogger.java:71) > at > org.apache.logging.log4j/org.apache.logging.log4j.LogManager.(LogManager.java:60) > {code} > Exception is a little bit misleading because it seems that true root cause > can be found here: > {code} > java.util.ServiceConfigurationError: > org.apache.logging.log4j.util.PropertySource: module org.apache.logging.log4j > does not declare `uses` > at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588) > at java.base/java.util.ServiceLoader.checkCaller(ServiceLoader.java:574) > at java.base/java.util.ServiceLoader.(ServiceLoader.java:503) > at java.base/java.util.ServiceLoader.load(ServiceLoader.java:1684) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil$Environment.(PropertiesUtil.java:319) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil$Environment.(PropertiesUtil.java:310) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil.(PropertiesUtil.java:69) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.PropertiesUtil.(PropertiesUtil.java:49) > at > org.apache.logging.log4j/org.apache.logging.log4j.util.Constants.(Constants.java:30) > at java.base/java.lang.Class.forName0(Native Method) > at java.base/java.lang.Class.forName(Class.java:375) > at > org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLogger.createClassForProperty(AbstractLogger.java:198) > at > org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLogger.(AbstractLogger.java:88) > at > org.apache.logging.log4j/org.apache.logging.log4j.LogManager.(LogManager.java:60) > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Comment Edited] (LOG4J2-2282) How i delete the old log files with 2.10.0
[ https://issues.apache.org/jira/browse/LOG4J2-2282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16401629#comment-16401629 ] Rehel edited comment on LOG4J2-2282 at 3/16/18 9:12 AM: Thanks for replying. Here is my integrations. {code:java} slf4j-api-1.7.25.jar log4j-api-2.10.0.jar log4j-core-2.10.0.jar log4j-slf4j-impl-2.10.0.jar{code} I guess it was what you wanted. Here is output. {code:java} 2018-03-16 12:09:08,657 main DEBUG Initializing configuration XmlConfiguration[location=/mnt/94E4DF48E4DF2B6E/JME/rhl/build/classes/log4j2.xml] 2018-03-16 12:09:08,667 main DEBUG Installed 2 script engines 2018-03-16 12:09:09,209 main DEBUG Oracle Nashorn version: 1.8.0_152, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory 2018-03-16 12:09:09,226 main DEBUG Groovy Scripting Engine version: 2.0, language: Groovy, threading: MULTITHREADED, compile: true, names: [groovy, Groovy], factory class: org.codehaus.groovy.jsr223.GroovyScriptEngineFactory 2018-03-16 12:09:09,228 main DEBUG PluginManager 'Core' found 116 plugins 2018-03-16 12:09:09,229 main DEBUG PluginManager 'Level' found 0 plugins 2018-03-16 12:09:09,237 main DEBUG PluginManager 'Lookup' found 13 plugins 2018-03-16 12:09:09,239 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. 2018-03-16 12:09:09,259 main TRACE TypeConverterRegistry initializing. 2018-03-16 12:09:09,264 main DEBUG PluginManager 'TypeConverter' found 26 plugins 2018-03-16 12:09:09,280 main DEBUG PatternLayout$Builder(pattern="%m%n", PatternSelector=null, Configuration(rhl), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null") 2018-03-16 12:09:09,281 main DEBUG PluginManager 'Converter' found 42 plugins 2018-03-16 12:09:09,282 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender]. 2018-03-16 12:09:09,301 main DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%m%n), name="STDOUT", Configuration(rhl), Filter=null) 2018-03-16 12:09:09,305 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false 2018-03-16 12:09:09,305 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. 2018-03-16 12:09:09,310 main DEBUG PatternLayout$Builder(pattern="%d %p %c{1.} [%t] %m%n", PatternSelector=null, Configuration(rhl), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null") 2018-03-16 12:09:09,334 main DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy]. 2018-03-16 12:09:09,343 main DEBUG TimeBasedTriggeringPolicy$Builder(interval="1", modulate="true", maxRandomDelay="null") 2018-03-16 12:09:09,343 main DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy]. 2018-03-16 12:09:09,353 main DEBUG createPolicy(size="50MB") 2018-03-16 12:09:09,354 main DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy]. 2018-03-16 12:09:09,359 main DEBUG createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=52428800)}) 2018-03-16 12:09:09,360 main DEBUG Building Plugin[name=Delete, class=org.apache.logging.log4j.core.appender.rolling.action.DeleteAction]. 2018-03-16 12:09:09,363 main ERROR Delete contains invalid attributes "IfFileName", "IfLastModified" 2018-03-16 12:09:09,363 main DEBUG createDeleteAction(basePath="logs/", followLinks="false", maxDepth="2", testMode="false", PathSorter=null, ={}, ScriptCondition=null, Configuration(rhl)) 2018-03-16 12:09:09,364 main ERROR Missing Delete conditions: unconditional Delete not supported 2018-03-16 12:09:09,364 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.rolling.action.DeleteAction for element Delete: java.lang.IllegalArgumentException: Unconditional Delete not supported java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:136) at
[jira] [Commented] (LOG4J2-2282) How i delete the old log files with 2.10.0
[ https://issues.apache.org/jira/browse/LOG4J2-2282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16401629#comment-16401629 ] Rehel commented on LOG4J2-2282: --- Here is my integrations. {code:java} slf4j-api-1.7.25.jar log4j-api-2.10.0.jar log4j-core-2.10.0.jar log4j-slf4j-impl-2.10.0.jar{code} I guess it was what you wanted. Here is output. {code:java} 2018-03-16 12:09:08,657 main DEBUG Initializing configuration XmlConfiguration[location=/mnt/94E4DF48E4DF2B6E/JME/rhl/build/classes/log4j2.xml] 2018-03-16 12:09:08,667 main DEBUG Installed 2 script engines 2018-03-16 12:09:09,209 main DEBUG Oracle Nashorn version: 1.8.0_152, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory 2018-03-16 12:09:09,226 main DEBUG Groovy Scripting Engine version: 2.0, language: Groovy, threading: MULTITHREADED, compile: true, names: [groovy, Groovy], factory class: org.codehaus.groovy.jsr223.GroovyScriptEngineFactory 2018-03-16 12:09:09,228 main DEBUG PluginManager 'Core' found 116 plugins 2018-03-16 12:09:09,229 main DEBUG PluginManager 'Level' found 0 plugins 2018-03-16 12:09:09,237 main DEBUG PluginManager 'Lookup' found 13 plugins 2018-03-16 12:09:09,239 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. 2018-03-16 12:09:09,259 main TRACE TypeConverterRegistry initializing. 2018-03-16 12:09:09,264 main DEBUG PluginManager 'TypeConverter' found 26 plugins 2018-03-16 12:09:09,280 main DEBUG PatternLayout$Builder(pattern="%m%n", PatternSelector=null, Configuration(rhl), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null") 2018-03-16 12:09:09,281 main DEBUG PluginManager 'Converter' found 42 plugins 2018-03-16 12:09:09,282 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender]. 2018-03-16 12:09:09,301 main DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%m%n), name="STDOUT", Configuration(rhl), Filter=null) 2018-03-16 12:09:09,305 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false 2018-03-16 12:09:09,305 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. 2018-03-16 12:09:09,310 main DEBUG PatternLayout$Builder(pattern="%d %p %c{1.} [%t] %m%n", PatternSelector=null, Configuration(rhl), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null") 2018-03-16 12:09:09,334 main DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy]. 2018-03-16 12:09:09,343 main DEBUG TimeBasedTriggeringPolicy$Builder(interval="1", modulate="true", maxRandomDelay="null") 2018-03-16 12:09:09,343 main DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy]. 2018-03-16 12:09:09,353 main DEBUG createPolicy(size="50MB") 2018-03-16 12:09:09,354 main DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy]. 2018-03-16 12:09:09,359 main DEBUG createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=52428800)}) 2018-03-16 12:09:09,360 main DEBUG Building Plugin[name=Delete, class=org.apache.logging.log4j.core.appender.rolling.action.DeleteAction]. 2018-03-16 12:09:09,363 main ERROR Delete contains invalid attributes "IfFileName", "IfLastModified" 2018-03-16 12:09:09,363 main DEBUG createDeleteAction(basePath="logs/", followLinks="false", maxDepth="2", testMode="false", PathSorter=null, ={}, ScriptCondition=null, Configuration(rhl)) 2018-03-16 12:09:09,364 main ERROR Missing Delete conditions: unconditional Delete not supported 2018-03-16 12:09:09,364 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.rolling.action.DeleteAction for element Delete: java.lang.IllegalArgumentException: Unconditional Delete not supported java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:136) at