I just noticed this never got replied to.  But I guess I need to add that I 
don’t understand why you need to do this, or how you expect it to work. It 
seems like you are trying to create a new Root Logger so you can add a custom 
attribute to it. I’m not really sure why since that custom attribute isn’t 
being recognized by Log4j. Furthermore, the LoggerConfig constructor you are 
calling requires 5 parameters. I don’t see a constructor that has 5 parameters.

Can you explain what the “use myAttr” code is doing in the constructor?

Ralph

> On May 19, 2020, at 4:22 AM, 南 温夫 <mina...@intellilink.co.jp> wrote:
> 
> Hello, I'd like to ask about LoggerConfig Plugin. I'm trying to add custom 
> attributes to my logger using LoggerConfig Plugin as following.
> 
> @Plugin(name = "MyLogger", category = "Core", printObject = true)
> public static class MyLoggerConfig extends LoggerConfig {
> 
>    @PluginFactory
>    public static LoggerConfig createLogger(@PluginAttribute(value = 
> "additivity", defaultBooleanValue = true) boolean additivity,
>                                            @PluginAttribute(value = "level", 
> defaultStringValue = "ERROR") Level level,
>                                            @PluginElement("AppenderRef") 
> AppenderRef[] refs,
>                                            @PluginElement("Filters") Filter 
> filter
>                                             @ PluginAttribute ("MyAttribute") 
> String myAttr) {
>        List<AppenderRef> appenderRefs = Arrays.asList(refs);
>        ... use myAttr
>        return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, 
> filter, level, additivity);
>    }
> }
> 
> https://logging.apache.org/log4j/2.x/manual/extending.html#LoggerConfig
> 
> This is work when I write in lo4j2.xml as below.
> <Loggers>
>       <MyLogger name="mylogger">
>       </MyLogger>
> </Loggers>
> 
> However, using log4j2.properties format it doesn't work.
> loggers = MyLogger
> logger.MyLogger.name = myLogger
> 
> I think this is because I should write properites setting same to xml like 
> below, but this is not correct.
> loggers = MyLogger
> MyLogger.name = myLogger
> 
> 
> It would be helpful if anyone knows how to use LoggerConfig plugin with 
> lo4j2.properies format setting. 
> I'm using latest version 2.13.3.
> 
> Regards
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to