logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 南 温夫 <mina...@intellilink.co.jp>
Subject How to use LoggerConfig Plugin with lo4j2.properties?
Date Tue, 19 May 2020 11:22:31 GMT
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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message