You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "martin-dorey-hv (via GitHub)" <gi...@apache.org> on 2024/10/10 22:36:56 UTC
[I] ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch" (logging-log4j2)
martin-dorey-hv opened a new issue, #3078:
URL: https://github.com/apache/logging-log4j2/issues/3078
Problem is at https://github.com/apache/logging-log4j2/blame/f7c26cd7710fdace463a370e85d0971107c91d8b/src/site/antora/modules/ROOT/examples/manual/pattern-layout/script-pattern-selector/log4j2.properties#L33
I suggest:
```
martind@stormy:~/tmp/D161042$ diff -u log4j2.properties{.orig,}
--- log4j2.properties.orig 2024-10-10 15:31:13.405464567 -0700
+++ log4j2.properties 2024-10-10 15:31:34.670434140 -0700
@@ -30,12 +30,12 @@
} else {\
return null;\
}
-appender.0.layout.patternSelector.patternMatch.0.type = PatternMatch
-appender.0.layout.patternSelector.patternMatch.0.key = NoLocation
-appender.0.layout.patternSelector.patternMatch.0.pattern = [%-5level] %c{1.} %msg%n
-appender.0.layout.patternSelector.patternMatch.1.type = PatternMatch
-appender.0.layout.patternSelector.patternMatch.1.key = Flow
-appender.0.layout.patternSelector.patternMatch.1.pattern = [%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n
+appender.0.layout.patternSelector.0.type = PatternMatch
+appender.0.layout.patternSelector.0.key = NoLocation
+appender.0.layout.patternSelector.0.pattern = [%-5level] %c{1.} %msg%n
+appender.0.layout.patternSelector.1.type = PatternMatch
+appender.0.layout.patternSelector.1.key = Flow
+appender.0.layout.patternSelector.1.pattern = [%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n
rootLogger.level = WARN
rootLogger.appenderRef.0.ref = CONSOLE
martind@stormy:~/tmp/D161042$
```
I didn't check whether it was the only instance of such a problem, sorry. I didn't even check whether there were any other problems in this file, let alone anything constructive such as why automated testing didn't catch this. I didn't find any other examples out on the internets. If I'm trying to provide search engine fodder, for the next poor sap, I should show the full presentation, which was this, once I'd got all my other problems out of the way:
```
Exception in thread "main" org.apache.logging.log4j.core.config.ConfigurationException: No type attribute provided for component patternMatch
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.createComponent(PropertiesConfigurationBuilder.java:338)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.processRemainingProperties(PropertiesConfigurationBuilder.java:353)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.createComponent(PropertiesConfigurationBuilder.java:341)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.processRemainingProperties(PropertiesConfigurationBuilder.java:353)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.createLayout(PropertiesConfigurationBuilder.java:330)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.createAppender(PropertiesConfigurationBuilder.java:223)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.build(PropertiesConfigurationBuilder.java:155)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:56)
at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:34)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:544)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:463)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:321)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:719)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:749)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:46)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:138)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:136)
at org.apache.commons.logging.impl.Log4jApiLogFactory$LogAdapter.getContext(Log4jApiLogFactory.java:161)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.commons.logging.impl.Log4jApiLogFactory.getInstance(Log4jApiLogFactory.java:210)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:933)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch" (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #3078:
URL: https://github.com/apache/logging-log4j2/issues/3078#issuecomment-2413263594
BTW: the `PropertiesConfigurationFactory` should not throw, when it encounters an invalid configuration file, but log an `ERROR` to the status logger. I reported this as #3088.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch" (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #3078: ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch"
URL: https://github.com/apache/logging-log4j2/issues/3078
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch" (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #3078:
URL: https://github.com/apache/logging-log4j2/issues/3078#issuecomment-2413258884
@martin-dorey-hv,
Nice catch! :100: Could you submit a PR to fix the problem?
> I didn't even check whether there were any other problems in this file, let alone anything constructive such as why automated testing didn't catch this.
We didn't integrate our code examples into our unit test suite. The `log4j2.properties` we converted manually from our `log4j2.xml` examples (which is the recommended format). Since the Java System properties configuration format is not used by the Log4j dev team and has [a lot of quirks](https://logging.apache.org/log4j/2.x/manual/configuration.html#java-properties-features), you might find many typos in the examples.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org