Skip to content

Commit

Permalink
Log4j respects the configured "log4j2.is.webapp" property
Browse files Browse the repository at this point in the history
Some applications run embedded servlet containers sharing
a single logging context from the root application.
  • Loading branch information
Carter Kozak committed Oct 26, 2017
1 parent f34d3cf commit e5f18e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
Expand Up @@ -46,7 +46,8 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba

private static final StatusLogger LOGGER = StatusLogger.getLogger();
private static final boolean SHUTDOWN_HOOK_ENABLED =
PropertiesUtil.getProperties().getBooleanProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, true);
PropertiesUtil.getProperties().getBooleanProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, true) &&
!Constants.IS_WEB_APP;

private final ContextSelector selector;
private final ShutdownCallbackRegistry shutdownCallbackRegistry;
Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.core.util.ReflectionUtil;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.Constants;

/**
* Proxies all the other {@link StrLookup}s.
Expand Down Expand Up @@ -115,7 +116,7 @@ public Interpolator(final Map<String, String> properties) {
}
lookups.put("date", new DateLookup());
lookups.put("ctx", new ContextMapLookup());
if (Loader.isClassAvailable("javax.servlet.ServletContext")) {
if (Constants.IS_WEB_APP) {
try {
lookups.put(LOOKUP_KEY_WEB,
Loader.newCheckedInstanceOf("org.apache.logging.log4j.web.WebLookup", StrLookup.class));
Expand Down
16 changes: 0 additions & 16 deletions log4j-web/src/main/resources/log4j2.component.properties

This file was deleted.

0 comments on commit e5f18e5

Please sign in to comment.