org.apache.logging.log4j.core.config.plugins.util.PluginManager Java Examples

The following examples show how to use org.apache.logging.log4j.core.config.plugins.util.PluginManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConstraintPlugins.java    From logging-log4j-audit with Apache License 2.0 7 votes vote down vote up
private ConstraintPlugins() {

        final PluginManager manager = new PluginManager(ConstraintType.CATEGORY);
        if (LOGGER instanceof org.apache.logging.log4j.core.Logger) {
            List<String> pluginPackages =
                    ((org.apache.logging.log4j.core.Logger) LOGGER).getContext().getConfiguration().getPluginPackages();
            manager.collectPlugins(pluginPackages);
        } else {
            manager.collectPlugins();
        }
        final Map<String, PluginType<?>> plugins = manager.getPlugins();
        for (Map.Entry<String, PluginType<?>> entry : plugins.entrySet()) {
            try {
                final Class<? extends ConstraintType> clazz = entry.getValue().getPluginClass().asSubclass(ConstraintType.class);
                ConstraintType constraintType = ReflectionUtil.instantiate(clazz);
                constraintMap.put(entry.getKey(), constraintType);
            } catch (final Throwable t) {
                throw new ConstraintCreationException("Unable to create constraint for " + entry.getKey(), t);
            }
        }
    }
 
Example #2
Source File: BuilderManager.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
public BuilderManager() {
    final PluginManager manager = new PluginManager(CATEGORY);
    manager.collectPlugins();
    plugins = manager.getPlugins();
}
 
Example #3
Source File: XMLConfigLogIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeClass
public static void setUp() {
    PluginManager.addPackage("com.baeldung.logging.log4j2.xmlconfiguration");
}
 
Example #4
Source File: SimpleConfigurationIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeClass
public static void setUp() {
    PluginManager.addPackage("com.baeldung.logging.log4j2.simpleconfiguration");
}
 
Example #5
Source File: LogConfigurator.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Load logging plugins so we can have {@code node_name} in the pattern.
 */
public static void loadLog4jPlugins() {
    PluginManager.addPackage(LogConfigurator.class.getPackage().getName());
}
 
Example #6
Source File: LogTest.java    From x-pipe with Apache License 2.0 3 votes vote down vote up
@Test
public void testPlugin(){
	
	PluginManager pm = new PluginManager(PatternConverter.CATEGORY);
	pm.collectPlugins();
	for(Entry<String, PluginType<?>> entry : pm.getPlugins().entrySet()){
		
		logger.info("{} : {}", entry.getKey(), entry.getValue());
		
	}
	
	logger.error("[testPlugin]", new IOException("io exception message..."));
}