Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3421

Programmatic Configuration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.17.1
    • None
    • None

    Description

      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:

       

          public Configuration getConfiguration(InputSource source) {        return new MyXMLConfiguration(source, configFile);    } 

      Where the configFile comes from??

       

       

          @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);    } 

      Where the refs come from??

       

       

      final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
      final Configuration config = context.getConfiguration(); 

      Really? No one was doing some kind of review on this?? Code snippets were done in plain text editors?

       

              LoggerConfig loggerConfig = LoggerConfig.createLogger("false", "info", "org.apache.logging.log4j",
                  "true", refs, null, config, null ); 

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sovikstepan Štěpán Sovík
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: