package cn.java.log4j2.demo.internal.other;
import org.apache.logging.log4j.core.config.plugins.processor.PluginCache;
import org.apache.logging.log4j.core.config.plugins.processor.PluginEntry;
import org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor;
import org.apache.logging.log4j.core.config.plugins.util.PluginType;
import org.apache.logging.log4j.core.util.Loader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
/**
*/
public class PluginCacheTest {
/**
* org.apache.logging.log4j.core.config.plugins.util.PluginRegistry#decodeCacheFiles(java.lang.ClassLoader)
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
final ClassLoader loader = Loader.getClassLoader();
final PluginCache cache = new PluginCache();
final Enumeration<URL> resources = loader.getResources(PluginProcessor.PLUGIN_CACHE_FILE);
if (resources == null) {
return;
} else {
/**
* 加载数据文件 DataOutputStream
*/
cache.loadCacheFiles(resources);
}
for (final Map.Entry<String, Map<String, PluginEntry>> outer : cache.getAllCategories().entrySet()) {
StringBuilder sb = new StringBuilder();
final String categoryLowerCase = outer.getKey();
sb.append("categoryLowerCase = ").append(categoryLowerCase).append("\n");
final List<PluginType<?>> types = new ArrayList<>(outer.getValue().size());
for (final Map.Entry<String, PluginEntry> inner : outer.getValue().entrySet()) {
final String pluginName = inner.getKey();
final PluginEntry entry = inner.getValue();
final String className = entry.getClassName();
sb.append("\tpluginName = ").append(pluginName).append(", className = ").append(className).append("\n");
}
System.out.println(sb);
}
// categoryLowerCase = core
// pluginName = property, className = org.apache.logging.log4j.core.config.Property
// pluginName = keystore, className = org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration
// pluginName = replace, className = org.apache.logging.log4j.core.pattern.RegexReplacement
// pluginName = scriptpatternselector, className = org.apache.logging.log4j.core.layout.ScriptPatternSelector
// pluginName = jeromq, className = org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppender
// pluginName = scriptref, className = org.apache.logging.log4j.core.script.ScriptRef
// pluginName = threadcontextmapfilter, className = org.apache.logging.log4j.core.filter.ThreadContextMapFilter
// pluginName = contextmapfilter, className = org.apache.logging.log4j.core.filter.ThreadContextMapFilter
// pluginName = linkedtransferqueue, className = org.apache.logging.log4j.core.async.LinkedTransferQueueFactory
// pluginName = yamllayout, className = org.apache.logging.log4j.core.layout.YamlLayout
// pluginName = scriptappenderselector, className = org.apache.logging.log4j.core.appender.ScriptAppenderSelector
// pluginName = null, className = org.apache.logging.log4j.core.appender.NullAppender
// pluginName = logger, className = org.apache.logging.log4j.core.config.LoggerConfig ------ <Logger>
// pluginName = root, className = org.apache.logging.log4j.core.config.LoggerConfig$RootLogger ------ <Root>
// pluginName = rollingrandomaccessfile, className = org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
// pluginName = arrayblockingqueue, className = org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory
// pluginName = socketoptions, className = org.apache.logging.log4j.core.net.SocketOptions
// pluginName = sizebasedtriggeringpolicy, className = org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy ------ <SizeBasedTriggeringPolicy>
// pluginName = disruptorblockingqueue, className = org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory
// pluginName = failovers, className = org.apache.logging.log4j.core.appender.FailoversPlugin
// pluginName = socketperformancepreferences, className = org.apache.logging.log4j.core.net.SocketPerformancePreferences
// pluginName = routing, className = org.apache.logging.log4j.core.appender.routing.RoutingAppender
// pluginName = loggerfields, className = org.apache.logging.log4j.core.layout.LoggerFields
// pluginName = patternmatch, className = org.apache.logging.log4j.core.layout.PatternMatch
// pluginName = datasource, className = org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource
// pluginName = levelrangefilter, className = org.apache.logging.log4j.core.filter.LevelRangeFilter
// pluginName = appenderset, className = org.apache.logging.log4j.core.appender.AppenderSet
// pluginName = timefilter, className = org.apache.logging.log4j.core.filter.TimeFilter
// pluginName = columnmapping, className = org.apache.logging.log4j.core.appender.db.ColumnMapping
// pluginName = ifaccumulatedfilesize, className = org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize
// pluginName = outputstream, className = org.apache.logging.log4j.core.appender.OutputStreamAppender
// pluginName = ifany, className = org.apache.logging.log4j.core.appender.rolling.action.IfAny
// pluginName = defaultrolloverstrategy, className = org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy
// pluginName = patternlayout, className = org.apache.logging.log4j.core.layout.PatternLayout ------ <PatternLayout>
// pluginName = smtp, className = org.apache.logging.log4j.core.appender.SmtpAppender
// pluginName = async, className = org.apache.logging.log4j.core.appender.AsyncAppender
// pluginName = appenders, className = org.apache.logging.log4j.core.config.AppendersPlugin
// pluginName = console, className = org.apache.logging.log4j.core.appender.ConsoleAppender ------ <Console>
// pluginName = customlevels, className = org.apache.logging.log4j.core.config.CustomLevels
// pluginName = policies, className = org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy ------ <Policies>
// pluginName = markerfilter, className = org.apache.logging.log4j.core.filter.MarkerFilter
// pluginName = script, className = org.apache.logging.log4j.core.script.Script
// pluginName = randomaccessfile, className = org.apache.logging.log4j.core.appender.RandomAccessFileAppender
// pluginName = xmllayout, className = org.apache.logging.log4j.core.layout.XmlLayout
// pluginName = customlevel, className = org.apache.logging.log4j.core.config.CustomLevelConfig
// pluginName = loggernamelevelrewritepolicy, className = org.apache.logging.log4j.core.appender.rewrite.LoggerNameLevelRewritePolicy
// pluginName = jsonlayout, className = org.apache.logging.log4j.core.layout.JsonLayout
// pluginName = csvlogeventlayout, className = org.apache.logging.log4j.core.layout.CsvLogEventLayout
// pluginName = csvparameterlayout, className = org.apache.logging.log4j.core.layout.CsvParameterLayout
// pluginName = http, className = org.apache.logging.log4j.core.appender.HttpAppender
// pluginName = nosql, className = org.apache.logging.log4j.core.appender.nosql.NoSqlAppender
// pluginName = default, className = org.apache.logging.log4j.core.config.DefaultAdvertiser
// pluginName = failover, className = org.apache.logging.log4j.core.appender.FailoverAppender
// pluginName = connectionfactory, className = org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource
// pluginName = scriptfilter, className = org.apache.logging.log4j.core.filter.ScriptFilter
// pluginName = asynclogger, className = org.apache.logging.log4j.core.async.AsyncLoggerConfig
// pluginName = asyncroot, className = org.apache.logging.log4j.core.async.AsyncLoggerConfig$RootLogger
// pluginName = file, className = org.apache.logging.log4j.core.appender.FileAppender
// pluginName = structureddatafilter, className = org.apache.logging.log4j.core.filter.StructuredDataFilter
// pluginName = route, className = org.apache.logging.log4j.core.appender.routing.Route
// pluginName = ssl, className = org.apache.logging.log4j.core.net.ssl.SslConfiguration
// pluginName = socketaddress, className = org.apache.logging.log4j.core.net.SocketAddress
// pluginName = keyvaluepair, className = org.apache.logging.log4j.core.util.KeyValuePair
// pluginName = rewrite, className = org.apache.logging.log4j.core.appender.rewrite.RewriteAppender
// pluginName = loggers, className = org.apache.logging.log4j.core.config.LoggersPlugin ------ <Loggers>
// pluginName = htmllayout, className = org.apache.logging.log4j.core.layout.HtmlLayout
// pluginName = filters, className = org.apache.logging.log4j.core.filter.CompositeFilter ------ <Filters>
// pluginName = properties, className = org.apache.logging.log4j.core.config.PropertiesPlugin
// pluginName = drivermanager, className = org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource
// pluginName = appenderref, className = org.apache.logging.log4j.core.config.AppenderRef
// pluginName = appender-ref, className = org.apache.logging.log4j.core.config.AppenderRef ------ <appender-ref>
// pluginName = column, className = org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig
// pluginName = rollingfile, className = org.apache.logging.log4j.core.appender.RollingFileAppender ------ <RollingFile>
// pluginName = scriptfile, className = org.apache.logging.log4j.core.script.ScriptFile
// pluginName = iffilename, className = org.apache.logging.log4j.core.appender.rolling.action.IfFileName
// pluginName = propertiesrewritepolicy, className = org.apache.logging.log4j.core.appender.rewrite.PropertiesRewritePolicy
// pluginName = idlepurgepolicy, className = org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy
// pluginName = jctoolsblockingqueue, className = org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory
// pluginName = directwriterolloverstrategy, className = org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy
// pluginName = scripts, className = org.apache.logging.log4j.core.config.ScriptsPlugin
// pluginName = truststore, className = org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration
// pluginName = memorymappedfile, className = org.apache.logging.log4j.core.appender.MemoryMappedFileAppender
// pluginName = multicastdns, className = org.apache.logging.log4j.core.net.MulticastDnsAdvertiser
// pluginName = timebasedtriggeringpolicy, className = org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy ------ <TimeBasedTriggeringPolicy>
// pluginName = countingnoop, className = org.apache.logging.log4j.core.appender.CountingNoOpAppender
// pluginName = socket, className = org.apache.logging.log4j.core.appender.SocketAppender
// pluginName = sortbymodificationtime, className = org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime
// pluginName = regexfilter, className = org.apache.logging.log4j.core.filter.RegexFilter
// pluginName = sysloglayout, className = org.apache.logging.log4j.core.layout.SyslogLayout
// pluginName = ifnot, className = org.apache.logging.log4j.core.appender.rolling.action.IfNot
// pluginName = markerpatternselector, className = org.apache.logging.log4j.core.layout.MarkerPatternSelector
// pluginName = delete, className = org.apache.logging.log4j.core.appender.rolling.action.DeleteAction
// pluginName = ifall, className = org.apache.logging.log4j.core.appender.rolling.action.IfAll
// pluginName = burstfilter, className = org.apache.logging.log4j.core.filter.BurstFilter
// pluginName = writer, className = org.apache.logging.log4j.core.appender.WriterAppender
// pluginName = ifaccumulatedfilecount, className = org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount
// pluginName = posixviewattribute, className = org.apache.logging.log4j.core.appender.rolling.action.PosixViewAttributeAction
// pluginName = mapfilter, className = org.apache.logging.log4j.core.filter.MapFilter
// pluginName = iflastmodified, className = org.apache.logging.log4j.core.appender.rolling.action.IfLastModified
// pluginName = messagelayout, className = org.apache.logging.log4j.core.layout.MessageLayout
// pluginName = routes, className = org.apache.logging.log4j.core.appender.routing.Routes
// pluginName = gelflayout, className = org.apache.logging.log4j.core.layout.GelfLayout
// pluginName = crontriggeringpolicy, className = org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy
// pluginName = onstartuptriggeringpolicy, className = org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy
// pluginName = serializedlayout, className = org.apache.logging.log4j.core.layout.SerializedLayout
// pluginName = maprewritepolicy, className = org.apache.logging.log4j.core.appender.rewrite.MapRewritePolicy
// pluginName = rfc5424layout, className = org.apache.logging.log4j.core.layout.Rfc5424Layout
// pluginName = syslog, className = org.apache.logging.log4j.core.appender.SyslogAppender
// pluginName = jdbc, className = org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender
// pluginName = scriptcondition, className = org.apache.logging.log4j.core.appender.rolling.action.ScriptCondition
// pluginName = jms, className = org.apache.logging.log4j.core.appender.mom.JmsAppender
// pluginName = jmsqueue, className = org.apache.logging.log4j.core.appender.mom.JmsAppender
// pluginName = jmstopic, className = org.apache.logging.log4j.core.appender.mom.JmsAppender
// pluginName = kafka, className = org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender
// pluginName = dynamicthresholdfilter, className = org.apache.logging.log4j.core.filter.DynamicThresholdFilter
// pluginName = thresholdfilter, className = org.apache.logging.log4j.core.filter.ThresholdFilter ------ <ThresholdFilter>
//
// categoryLowerCase = converter
// pluginName = highlight, className = org.apache.logging.log4j.core.pattern.HighlightConverter
// pluginName = replace, className = org.apache.logging.log4j.core.pattern.RegexReplacementConverter
// pluginName = datepatternconverter, className = org.apache.logging.log4j.core.pattern.DatePatternConverter
// pluginName = lineseparatorpatternconverter, className = org.apache.logging.log4j.core.pattern.LineSeparatorPatternConverter
// pluginName = ndcpatternconverter, className = org.apache.logging.log4j.core.pattern.NdcPatternConverter
// pluginName = endofbatchpatternconverter, className = org.apache.logging.log4j.core.pattern.EndOfBatchPatternConverter
// pluginName = fulllocationpatternconverter, className = org.apache.logging.log4j.core.pattern.FullLocationPatternConverter
// pluginName = levelpatternconverter, className = org.apache.logging.log4j.core.pattern.LevelPatternConverter
// pluginName = uuidpatternconverter, className = org.apache.logging.log4j.core.pattern.UuidPatternConverter
// pluginName = mappatternconverter, className = org.apache.logging.log4j.core.pattern.MapPatternConverter
// pluginName = filelocationpatternconverter, className = org.apache.logging.log4j.core.pattern.FileLocationPatternConverter
// pluginName = relativetimepatternconverter, className = org.apache.logging.log4j.core.pattern.RelativeTimePatternConverter
// pluginName = threadprioritypatternconverter, className = org.apache.logging.log4j.core.pattern.ThreadPriorityPatternConverter
// pluginName = methodlocationpatternconverter, className = org.apache.logging.log4j.core.pattern.MethodLocationPatternConverter
// pluginName = classnamepatternconverter, className = org.apache.logging.log4j.core.pattern.ClassNamePatternConverter
// pluginName = style, className = org.apache.logging.log4j.core.pattern.StyleConverter
// pluginName = black, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Black
// pluginName = blue, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Blue
// pluginName = cyan, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Cyan
// pluginName = green, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Green
// pluginName = magenta, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Magenta
// pluginName = red, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Red
// pluginName = white, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$White
// pluginName = yellow, className = org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Yellow
// pluginName = linelocationpatternconverter, className = org.apache.logging.log4j.core.pattern.LineLocationPatternConverter
// pluginName = throwablepatternconverter, className = org.apache.logging.log4j.core.pattern.ThrowablePatternConverter
// pluginName = markernamepatternconverter, className = org.apache.logging.log4j.core.pattern.MarkerSimpleNamePatternConverter
// pluginName = loggerpatternconverter, className = org.apache.logging.log4j.core.pattern.LoggerPatternConverter
// pluginName = nanotimepatternconverter, className = org.apache.logging.log4j.core.pattern.NanoTimePatternConverter
// pluginName = equals, className = org.apache.logging.log4j.core.pattern.EqualsReplacementConverter
// pluginName = equalsignorecase, className = org.apache.logging.log4j.core.pattern.EqualsIgnoreCaseReplacementConverter
// pluginName = encode, className = org.apache.logging.log4j.core.pattern.EncodingPatternConverter
// pluginName = extendedthrowablepatternconverter, className = org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter
// pluginName = markerpatternconverter, className = org.apache.logging.log4j.core.pattern.MarkerPatternConverter
// pluginName = maxlength, className = org.apache.logging.log4j.core.pattern.MaxLengthConverter
// pluginName = threadidpatternconverter, className = org.apache.logging.log4j.core.pattern.ThreadIdPatternConverter
// pluginName = messagepatternconverter, className = org.apache.logging.log4j.core.pattern.MessagePatternConverter
// pluginName = sequencenumberpatternconverter, className = org.apache.logging.log4j.core.pattern.SequenceNumberPatternConverter
// pluginName = notempty, className = org.apache.logging.log4j.core.pattern.VariablesNotEmptyReplacementConverter
// pluginName = threadpatternconverter, className = org.apache.logging.log4j.core.pattern.ThreadNamePatternConverter
// pluginName = rootthrowablepatternconverter, className = org.apache.logging.log4j.core.pattern.RootThrowablePatternConverter
// pluginName = loggerfqcnpatternconverter, className = org.apache.logging.log4j.core.pattern.LoggerFqcnPatternConverter
// pluginName = processidpatternconverter, className = org.apache.logging.log4j.core.pattern.ProcessIdPatternConverter
// pluginName = mdcpatternconverter, className = org.apache.logging.log4j.core.pattern.MdcPatternConverter
//
// categoryLowerCase = lookup
// pluginName = sd, className = org.apache.logging.log4j.core.lookup.StructuredDataLookup
// pluginName = marker, className = org.apache.logging.log4j.core.lookup.MarkerLookup
// pluginName = jndi, className = org.apache.logging.log4j.core.lookup.JndiLookup
// pluginName = date, className = org.apache.logging.log4j.core.lookup.DateLookup
// pluginName = env, className = org.apache.logging.log4j.core.lookup.EnvironmentLookup
// pluginName = jvmrunargs, className = org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup
// pluginName = log4j, className = org.apache.logging.log4j.core.lookup.Log4jLookup
// pluginName = java, className = org.apache.logging.log4j.core.lookup.JavaLookup
// pluginName = map, className = org.apache.logging.log4j.core.lookup.MapLookup
// pluginName = bundle, className = org.apache.logging.log4j.core.lookup.ResourceBundleLookup
// pluginName = ctx, className = org.apache.logging.log4j.core.lookup.ContextMapLookup
// pluginName = main, className = org.apache.logging.log4j.core.lookup.MainMapLookup
// pluginName = sys, className = org.apache.logging.log4j.core.lookup.SystemPropertiesLookup
//
// categoryLowerCase = configurationfactory
// pluginName = yamlconfigurationfactory, className = org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory
// pluginName = xmlconfigurationfactory, className = org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory
// pluginName = jsonconfigurationfactory, className = org.apache.logging.log4j.core.config.json.JsonConfigurationFactory
// pluginName = propertiesconfigurationfactory, className = org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory
//
// categoryLowerCase = fileconverter
// pluginName = integerpatternconverter, className = org.apache.logging.log4j.core.pattern.IntegerPatternConverter
// pluginName = filedatepatternconverter, className = org.apache.logging.log4j.core.pattern.FileDatePatternConverter
//
// categoryLowerCase = typeconverter
// pluginName = bigdecimal, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BigDecimalConverter
// pluginName = biginteger, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BigIntegerConverter
// pluginName = boolean, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BooleanConverter
// pluginName = bytearray, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ByteArrayConverter
// pluginName = byte, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ByteConverter
// pluginName = character, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharacterConverter
// pluginName = characterarray, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharArrayConverter
// pluginName = charset, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharsetConverter
// pluginName = class, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ClassConverter
// pluginName = cronexpression, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CronExpressionConverter
// pluginName = double, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$DoubleConverter
// pluginName = duration, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$DurationConverter
// pluginName = file, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$FileConverter
// pluginName = float, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$FloatConverter
// pluginName = inetaddress, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$InetAddressConverter
// pluginName = integer, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$IntegerConverter
// pluginName = level, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$LevelConverter
// pluginName = long, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$LongConverter
// pluginName = path, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$PathConverter
// pluginName = pattern, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$PatternConverter
// pluginName = securityprovider, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$SecurityProviderConverter
// pluginName = short, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ShortConverter
// pluginName = string, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$StringConverter
// pluginName = uri, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UriConverter
// pluginName = url, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UrlConverter
// pluginName = uuid, className = org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UuidConverter
}
}