ConfigListConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { List<String> options = getOptionList(); String path = options.get(0); String index = options.get(1); try { Config config = (Config) getContext().getObject(ConfigConstants.TYPESAFE_CONFIG_CTX_KEY); if (path == null) { addError("No option found - you must specify property as %config{some.property.array,0} "); return "%PARSER_ERROR"; } ConfigList configList = config.getList(path); ConfigValue configValue = configList.get(Integer.parseInt(index)); return configValue.unwrapped().toString(); } catch (ConfigException e) { addError( String.format( "Exception rendering path %s, index %s, exception %s", path, index, e.getMessage())); return "%PARSER_ERROR"; } }  @Override String convert(ILoggingEvent event);  }
@Test public void testConversion() { LoggerContext context = new LoggerContext(); ConfigListConverter configValueConverter = new ConfigListConverter(); Config config = ConfigFactory.parseString("some.property.name=[one,two,three]"); context.putObject(TYPESAFE_CONFIG_CTX_KEY, config); configValueConverter.setContext(context); configValueConverter.setOptionList(Arrays.asList("some.property.name", "1")); configValueConverter.start(); String actual = configValueConverter.convert(null); assertThat(actual).isEqualTo("two"); }