"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

LoggerContext.java  (apache-log4j-2.11.1-src):LoggerContext.java  (apache-log4j-2.11.2-src)
skipping to change at line 45 skipping to change at line 45
import org.apache.logging.log4j.core.config.ConfigurationFactory; import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationListener; import org.apache.logging.log4j.core.config.ConfigurationListener;
import org.apache.logging.log4j.core.config.ConfigurationSource; import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.DefaultConfiguration; import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.config.NullConfiguration; import org.apache.logging.log4j.core.config.NullConfiguration;
import org.apache.logging.log4j.core.config.Reconfigurable; import org.apache.logging.log4j.core.config.Reconfigurable;
import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.jmx.Server; import org.apache.logging.log4j.core.jmx.Server;
import org.apache.logging.log4j.core.util.Cancellable; import org.apache.logging.log4j.core.util.Cancellable;
import org.apache.logging.log4j.core.util.ExecutorServices; import org.apache.logging.log4j.core.util.ExecutorServices;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.core.util.NetUtils; import org.apache.logging.log4j.core.util.NetUtils;
import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry; import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry;
import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.spi.AbstractLogger; import org.apache.logging.log4j.spi.AbstractLogger;
import org.apache.logging.log4j.spi.LoggerContextFactory; import org.apache.logging.log4j.spi.LoggerContextFactory;
import org.apache.logging.log4j.spi.LoggerRegistry; import org.apache.logging.log4j.spi.LoggerRegistry;
import org.apache.logging.log4j.spi.Terminable; import org.apache.logging.log4j.spi.Terminable;
import org.apache.logging.log4j.spi.ThreadContextMapFactory; import org.apache.logging.log4j.spi.ThreadContextMapFactory;
import org.apache.logging.log4j.util.LoaderUtil;
import org.apache.logging.log4j.util.PropertiesUtil; import org.apache.logging.log4j.util.PropertiesUtil;
/** /**
* The LoggerContext is the anchor for the logging system. It maintains a list o f all the loggers requested by * The LoggerContext is the anchor for the logging system. It maintains a list o f all the loggers requested by
* applications and a reference to the Configuration. The Configuration will con tain the configured loggers, appenders, * applications and a reference to the Configuration. The Configuration will con tain the configured loggers, appenders,
* filters, etc and will be atomically updated whenever a reconfigure occurs. * filters, etc and will be atomically updated whenever a reconfigure occurs.
*/ */
public class LoggerContext extends AbstractLifeCycle public class LoggerContext extends AbstractLifeCycle
implements org.apache.logging.log4j.spi.LoggerContext, AutoCloseable, Te rminable, ConfigurationListener { implements org.apache.logging.log4j.spi.LoggerContext, AutoCloseable, Te rminable, ConfigurationListener {
static { static {
try { try {
// LOG4J2-1642 preload ExecutorServices as it is used in shutdown ho ok // LOG4J2-1642 preload ExecutorServices as it is used in shutdown ho ok
LoaderUtil.loadClass(ExecutorServices.class.getName()); Loader.loadClass(ExecutorServices.class.getName());
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.error("Failed to preload ExecutorServices class.", e); LOGGER.error("Failed to preload ExecutorServices class.", e);
} }
} }
/** /**
* Property name of the property change event fired if the configuration is changed. * Property name of the property change event fired if the configuration is changed.
*/ */
public static final String PROPERTY_CONFIG = "config"; public static final String PROPERTY_CONFIG = "config";
skipping to change at line 492 skipping to change at line 492
* Determines if the specified Logger exists. * Determines if the specified Logger exists.
* *
* @param name The Logger name to search for. * @param name The Logger name to search for.
* @return True if the Logger exists, false otherwise. * @return True if the Logger exists, false otherwise.
*/ */
@Override @Override
public boolean hasLogger(final String name, final Class<? extends MessageFac tory> messageFactoryClass) { public boolean hasLogger(final String name, final Class<? extends MessageFac tory> messageFactoryClass) {
return loggerRegistry.hasLogger(name, messageFactoryClass); return loggerRegistry.hasLogger(name, messageFactoryClass);
} }
/** /**
* Returns the current Configuration. The Configuration will be replaced whe * Returns the current Configuration. The Configuration will be replaced
n a reconfigure occurs. when a reconfigure occurs.
* *
* @return The Configuration. * @return The current Configuration, never {@code null}, but may be
*/ * {@link org.apache.logging.log4j.core.config.NullConfiguration}.
public Configuration getConfiguration() { */
return configuration; public Configuration getConfiguration() {
} return configuration;
}
/** /**
* Adds a Filter to the Configuration. Filters that are added through the AP I will be lost when a reconfigure * Adds a Filter to the Configuration. Filters that are added through the AP I will be lost when a reconfigure
* occurs. * occurs.
* *
* @param filter The Filter to add. * @param filter The Filter to add.
*/ */
public void addFilter(final Filter filter) { public void addFilter(final Filter filter) {
configuration.addFilter(filter); configuration.addFilter(filter);
} }
skipping to change at line 526 skipping to change at line 527
public void removeFilter(final Filter filter) { public void removeFilter(final Filter filter) {
configuration.removeFilter(filter); configuration.removeFilter(filter);
} }
/** /**
* Sets the Configuration to be used. * Sets the Configuration to be used.
* *
* @param config The new Configuration. * @param config The new Configuration.
* @return The previous Configuration. * @return The previous Configuration.
*/ */
private Configuration setConfiguration(final Configuration config) { public Configuration setConfiguration(final Configuration config) {
if (config == null) { if (config == null) {
LOGGER.error("No configuration found for context '{}'.", contextName ); LOGGER.error("No configuration found for context '{}'.", contextName );
// No change, return the current configuration. // No change, return the current configuration.
return this.configuration; return this.configuration;
} }
configLock.lock(); configLock.lock();
try { try {
final Configuration prev = this.configuration; final Configuration prev = this.configuration;
config.addListener(this); config.addListener(this);
skipping to change at line 664 skipping to change at line 665
} }
firePropertyChangeEvent(new PropertyChangeEvent(this, PROPERTY_CONFIG, o ld, config)); firePropertyChangeEvent(new PropertyChangeEvent(this, PROPERTY_CONFIG, o ld, config));
} }
/** /**
* Causes a reconfiguration to take place when the underlying configuration file changes. * Causes a reconfiguration to take place when the underlying configuration file changes.
* *
* @param reconfigurable The Configuration that can be reconfigured. * @param reconfigurable The Configuration that can be reconfigured.
*/ */
@Override @Override
public synchronized void onChange(final Reconfigurable reconfigurable) { public synchronized void onChange(final Reconfigurable reconfigurable) {
LOGGER.debug("Reconfiguration started for context {} ({})", contextName, final long startMillis = System.currentTimeMillis();
this); LOGGER.debug("Reconfiguration started for context {} ({})", conte
initApiModule(); xtName, this);
final Configuration newConfig = reconfigurable.reconfigure(); initApiModule();
if (newConfig != null) { final Configuration newConfig = reconfigurable.reconfigure();
setConfiguration(newConfig); if (newConfig != null) {
LOGGER.debug("Reconfiguration completed for {} ({})", contextName, t setConfiguration(newConfig);
his); LOGGER.debug("Reconfiguration completed for {} ({}) in {}
} else { milliseconds.", contextName, this,
LOGGER.debug("Reconfiguration failed for {} ({})", contextName, this System.currentTimeMillis() - startMillis)
); ;
} } else {
} LOGGER.debug("Reconfiguration failed for {} ({}) in {} mi
lliseconds.", contextName, this,
System.currentTimeMillis() - startMillis)
;
}
}
private void initApiModule() { private void initApiModule() {
ThreadContextMapFactory.init(); // Or make public and call ThreadContext .init() which calls ThreadContextMapFactory.init(). ThreadContextMapFactory.init(); // Or make public and call ThreadContext .init() which calls ThreadContextMapFactory.init().
} }
// LOG4J2-151: changed visibility from private to protected // LOG4J2-151: changed visibility from private to protected
protected Logger newInstance(final LoggerContext ctx, final String name, fin al MessageFactory messageFactory) { protected Logger newInstance(final LoggerContext ctx, final String name, fin al MessageFactory messageFactory) {
return new Logger(ctx, name, messageFactory); return new Logger(ctx, name, messageFactory);
} }
 End of changes. 6 change blocks. 
26 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)