Package ch.qos.logback.classic.selector
Class ContextJNDISelector
- java.lang.Object
-
- ch.qos.logback.classic.selector.ContextJNDISelector
-
- All Implemented Interfaces:
ContextSelector
public class ContextJNDISelector extends java.lang.Object implements ContextSelector
A class that allows the LoggerFactory to access an environment-based LoggerContext. To add in catalina.sh JAVA_OPTS="$JAVA_OPTS "-Dlogback.ContextSelector=JNDI""
-
-
Field Summary
Fields Modifier and Type Field Description private LoggerContextdefaultContextprivate java.util.Map<java.lang.String,LoggerContext>synchronizedContextMapprivate static java.lang.ThreadLocal<LoggerContext>threadLocal
-
Constructor Summary
Constructors Constructor Description ContextJNDISelector(LoggerContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidconfigureLoggerContextByURL(LoggerContext context, java.net.URL url)private java.lang.StringconventionalConfigFileName(java.lang.String contextName)LoggerContextdetachLoggerContext(java.lang.String loggerContextName)private java.net.URLfindConfigFileURL(javax.naming.Context ctx, LoggerContext loggerContext)java.util.List<java.lang.String>getContextNames()intgetCount()Returns the number of managed contexts Used for testing purposesLoggerContextgetDefaultLoggerContext()LoggerContextgetLoggerContext()LoggerContextgetLoggerContext(java.lang.String name)voidremoveLocalContext()voidsetLocalContext(LoggerContext context)These methods are used by the LoggerContextFilter.private java.net.URLurlByResourceName(StatusManager sm, java.lang.String resourceName)
-
-
-
Field Detail
-
synchronizedContextMap
private final java.util.Map<java.lang.String,LoggerContext> synchronizedContextMap
-
defaultContext
private final LoggerContext defaultContext
-
threadLocal
private static final java.lang.ThreadLocal<LoggerContext> threadLocal
-
-
Constructor Detail
-
ContextJNDISelector
public ContextJNDISelector(LoggerContext context)
-
-
Method Detail
-
getDefaultLoggerContext
public LoggerContext getDefaultLoggerContext()
- Specified by:
getDefaultLoggerContextin interfaceContextSelector
-
detachLoggerContext
public LoggerContext detachLoggerContext(java.lang.String loggerContextName)
- Specified by:
detachLoggerContextin interfaceContextSelector
-
getLoggerContext
public LoggerContext getLoggerContext()
- Specified by:
getLoggerContextin interfaceContextSelector
-
conventionalConfigFileName
private java.lang.String conventionalConfigFileName(java.lang.String contextName)
-
findConfigFileURL
private java.net.URL findConfigFileURL(javax.naming.Context ctx, LoggerContext loggerContext)
-
urlByResourceName
private java.net.URL urlByResourceName(StatusManager sm, java.lang.String resourceName)
-
configureLoggerContextByURL
private void configureLoggerContextByURL(LoggerContext context, java.net.URL url)
-
getContextNames
public java.util.List<java.lang.String> getContextNames()
- Specified by:
getContextNamesin interfaceContextSelector
-
getLoggerContext
public LoggerContext getLoggerContext(java.lang.String name)
- Specified by:
getLoggerContextin interfaceContextSelector
-
getCount
public int getCount()
Returns the number of managed contexts Used for testing purposes- Returns:
- the number of managed contexts
-
setLocalContext
public void setLocalContext(LoggerContext context)
These methods are used by the LoggerContextFilter. They provide a way to tell the selector which context to use, thus saving the cost of a JNDI call at each new request.- Parameters:
context-
-
removeLocalContext
public void removeLocalContext()
-
-