I don't think that's possible in the current plugin system without
copying a bunch of code from AbstractConfiguration or similar. The
code for translating configurations into objects works starting from
the root configuration object. Ideally, the next gen plugin system
will be able to support something along the lines of what you're
asking for, though (i.e., being more of a generic way of configuring
beans rather than being purely tied to a log4j configuration).

On Fri, Dec 3, 2021 at 3:23 PM Volkan Yazıcı <[email protected]> wrote:
>
> Given a JSON snippet for configuring a layout, how can I instantiate the
> layout class itself? I have tried the following, which "runs" without a
> failure, but couldn't access to a layout:
>
> LoggerContext context = (LoggerContext) LogManager.getContext();
> ConfigurationSource configSource =
>         new ConfigurationSource(
>                 new ByteArrayInputStream(
>                         ("{'PatternLayout': {'MarkerPatternSelector': {" +
>                                 "'defaultPattern': '%m%n', " +
>                                 "'PatternMatch': {'key': 'FLOW',
> 'pattern': '===%m===%n'}" +
>                                 "}}}")
>                                 .replaceAll("'", "\"")
>                                 .getBytes(StandardCharsets.UTF_8)));
> JsonConfiguration configuration = new JsonConfiguration(context, 
> configSource);
>
> Eventually I want to obtain a Layout<?> instance. Any ideas?

Reply via email to