Štěpán Sovík created LOG4J2-3421:
------------------------------------
Summary: 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
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)