Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.classic.sift;
This discriminator returns the value context as determined by JNDI. If the said value is null, then a default value is returned.

Both Key and the DefaultValue are user specified properties.

Ceki Gülcü
public class JNDIBasedContextDiscriminator extends ContextAwareBase implements
  private static final String KEY = "contextName";
  private String defaultValue;
  private boolean started = false;

Return the name of the current context name as found in the logging event.
    ContextSelector selector = ContextSelectorStaticBinder.getSingleton()
    if (selector == null) {
      return ;
    LoggerContext lc = selector.getLoggerContext();
    if (lc == null) {
      return ;
    return lc.getName();
  public boolean isStarted() {
    return ;
  public void start() {
     = true;
  public void stop() {
     = false;
  public String getKey() {
    return ;
  public void setKey(String key) {
    throw new UnsupportedOperationException(
        "Key cannot be set. Using fixed key " + );

  public String getDefaultValue() {
    return ;

The default context name in case the context name is not set for the current logging event.

  public void setDefaultValue(String defaultValue) {
    this. = defaultValue;
New to GrepCode? Check out our FAQ X