Skip to content

ScriptPatternSelector properties example throws "No type attribute provided for component patternMatch" #3078

Closed
@martin-dorey-hv

Description

@martin-dorey-hv

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting-for-userMore information is needed from the user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions