I do not, no, though that sounds like the default configuration you’re looking 
at?

Matt Sicker

> On Dec 3, 2021, at 16:36, Volkan Yazıcı <[email protected]> wrote:
> 
> I think I have pulled it out: after doing a configuration.start(),
> configuration.getAppenders().values().iterator().next().getLayout() does
> the trick. Even though I did not specify an appender, the configuration
> creates a default ConsoleAppender using the layout I have provided. Matt,
> do you know the magic going on here?
> 
>> On Fri, Dec 3, 2021 at 11:24 PM Matt Sicker <[email protected]> wrote:
>> 
>> 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