[ https://issues.apache.org/jira/browse/LOG4J2-3421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17500362#comment-17500362 ]
Matt Sicker commented on LOG4J2-3421: ------------------------------------- Seems as though this custom config example has an actual code snippet in the log4j-samples module: [https://github.com/apache/logging-log4j2/tree/release-2.x/log4j-samples/log4j-samples-configuration/src/main/java/org/apache/logging/log4j/configuration] as well as this test showing some custom config changes: [https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java] > Programmatic Configuration > -------------------------- > > Key: LOG4J2-3421 > URL: https://issues.apache.org/jira/browse/LOG4J2-3421 > Project: Log4j 2 > Issue Type: Bug > Components: Configuration, Documentation > Affects Versions: 2.17.1 > Reporter: Štěpán Sovík > Priority: Major > > The documentation provided here: > [https://logging.apache.org/log4j/2.x/manual/customconfig.html] contains > plenty of 'code snippets' that are using deprecated API, non-compilable > issues ... and even when one fixes all, it still doesn't work. > Documentation issues need to be fixed and documentation updated so it's > obvious how it should actually work. > Just some examples: > > {code:java} > public Configuration getConfiguration(InputSource source) { return > new MyXMLConfiguration(source, configFile); } {code} > Where the configFile comes from?? > > > {code:java} > @Override protected void doConfigure() { super.doConfigure(); > final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); > final Configuration config = context.getConfiguration(); final > Layout layout = PatternLayout.createDefaultLayout(config); final > Appender appender = FileAppender.createAppender("target/test.log", "false", > "false", "File", "true", "false", "false", "4000", layout, null, > "false", null, config); appender.start(); > addAppender(appender); LoggerConfig loggerConfig = > LoggerConfig.createLogger("false", "info", "org.apache.logging.log4j", > "true", refs, null, config, null ); > loggerConfig.addAppender(appender, null, null); > addLogger("org.apache.logging.log4j", loggerConfig); } {code} > Where the refs come from?? > > > {code:java} > final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); > final Configuration config = context.getConfiguration(); {code} > Really? No one was doing some kind of review on this?? Code snippets were > done in plain text editors? > > {code:java} > LoggerConfig loggerConfig = LoggerConfig.createLogger("false", > "info", "org.apache.logging.log4j", > "true", refs, null, config, null ); {code} > Come on! This cannot be even compiled ... because "{_}The method > createLogger(String, Level, String, String, AppenderRef[], Property[], > Configuration, Filter) in the type LoggerConfig is not applicable for the > arguments (String, String, String, String, AppenderRef[], null, > Configuration, null){_}" > I've never seen such a badly documented feature before. -- This message was sent by Atlassian Jira (v8.20.1#820001)