log4j-1.2.14

16:38:54.088 INFO  jd.cli.Main - Decompiling log4j-1.2.14.jar
package org.apache.log4j;

import org.apache.log4j.spi.ErrorHandler;
import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;

public abstract interface Appender
{
  public abstract void addFilter(Filter paramFilter);
  
  public abstract Filter getFilter();
  
  public abstract void clearFilters();
  
  public abstract void close();
  
  public abstract void doAppend(LoggingEvent paramLoggingEvent);
  
  public abstract String getName();
  
  public abstract void setErrorHandler(ErrorHandler paramErrorHandler);
  
  public abstract ErrorHandler getErrorHandler();
  
  public abstract void setLayout(Layout paramLayout);
  
  public abstract Layout getLayout();
  
  public abstract void setName(String paramString);
  
  public abstract boolean requiresLayout();
}

/* Location:
 * Qualified Name:     org.apache.log4j.Appender
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.helpers.OnlyOnceErrorHandler;
import org.apache.log4j.spi.ErrorHandler;
import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.OptionHandler;

public abstract class AppenderSkeleton
  implements Appender, OptionHandler
{
  protected Layout layout;
  protected String name;
  protected Priority threshold;
  protected ErrorHandler errorHandler = new OnlyOnceErrorHandler();
  protected Filter headFilter;
  protected Filter tailFilter;
  protected boolean closed = false;
  
  public void activateOptions() {}
  
  public void addFilter(Filter newFilter)
  {
    if (headFilter == null)
    {
      headFilter = (tailFilter = newFilter);
    }
    else
    {
      tailFilter.next = newFilter;
      tailFilter = newFilter;
    }
  }
  
  protected abstract void append(LoggingEvent paramLoggingEvent);
  
  public void clearFilters()
  {
    headFilter = (tailFilter = null);
  }
  
  public void finalize()
  {
    if (closed) {
      return;
    }
    LogLog.debug("Finalizing appender named [" + name + "].");
    close();
  }
  
  public ErrorHandler getErrorHandler()
  {
    return errorHandler;
  }
  
  public Filter getFilter()
  {
    return headFilter;
  }
  
  public final Filter getFirstFilter()
  {
    return headFilter;
  }
  
  public Layout getLayout()
  {
    return layout;
  }
  
  public final String getName()
  {
    return name;
  }
  
  public Priority getThreshold()
  {
    return threshold;
  }
  
  public boolean isAsSevereAsThreshold(Priority priority)
  {
    return (threshold == null) || (priority.isGreaterOrEqual(threshold));
  }
  
  public synchronized void doAppend(LoggingEvent event)
  {
    if (closed)
    {
      LogLog.error("Attempted to append to closed appender named [" + name + "].");
      return;
    }
    if (!isAsSevereAsThreshold(event.getLevel())) {
      return;
    }
    Filter f = headFilter;
    while (f != null) {
      switch (f.decide(event))
      {
      case -1: 
        return;
      case 1: 
        break;
      case 0: 
        f = next;
      }
    }
    append(event);
  }
  
  public synchronized void setErrorHandler(ErrorHandler eh)
  {
    if (eh == null) {
      LogLog.warn("You have tried to set a null error-handler.");
    } else {
      errorHandler = eh;
    }
  }
  
  public void setLayout(Layout layout)
  {
    this.layout = layout;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public void setThreshold(Priority threshold)
  {
    this.threshold = threshold;
  }
  
  public abstract boolean requiresLayout();
  
  public abstract void close();
}

/* Location:
 * Qualified Name:     org.apache.log4j.AppenderSkeleton
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.text.MessageFormat;
import org.apache.log4j.spi.LoggingEvent;

final class AsyncAppender$DiscardSummary
{
  private LoggingEvent maxEvent;
  private int count;
  
  public AsyncAppender$DiscardSummary(LoggingEvent event)
  {
    maxEvent = event;
    count = 1;
  }
  
  public void add(LoggingEvent event)
  {
    if (event.getLevel().toInt() > maxEvent.getLevel().toInt()) {
      maxEvent = event;
    }
    count += 1;
  }
  
  public LoggingEvent createEvent()
  {
    String msg = MessageFormat.format("Discarded {0} messages due to full event buffer including: {1}", new Object[] { new Integer(count), maxEvent.getMessage() });
    
    return new LoggingEvent(null, Logger.getLogger(maxEvent.getLoggerName()), maxEvent.getLevel(), msg, null);
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.AsyncAppender.DiscardSummary
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.log4j.helpers.AppenderAttachableImpl;
import org.apache.log4j.spi.LoggingEvent;

class AsyncAppender$Dispatcher
  implements Runnable
{
  private final AsyncAppender parent;
  private final List buffer;
  private final Map discardMap;
  private final AppenderAttachableImpl appenders;
  
  public AsyncAppender$Dispatcher(AsyncAppender parent, List buffer, Map discardMap, AppenderAttachableImpl appenders)
  {
    this.parent = parent;
    this.buffer = buffer;
    this.appenders = appenders;
    this.discardMap = discardMap;
  }
  
  public void run()
  {
    boolean isActive = true;
    try
    {
      while (isActive)
      {
        LoggingEvent[] events = null;
        synchronized (buffer)
        {
          int bufferSize = buffer.size();
          isActive = !parent.closed;
          while ((bufferSize == 0) && (isActive))
          {
            buffer.wait();
            bufferSize = buffer.size();
            isActive = !parent.closed;
          }
          if (bufferSize > 0)
          {
            events = new LoggingEvent[bufferSize + discardMap.size()];
            buffer.toArray(events);
            
            ??? = bufferSize;
            
            Iterator iter = discardMap.values().iterator();
            while (iter.hasNext()) {
              events[(???++)] = ((AsyncAppender.DiscardSummary)iter.next()).createEvent();
            }
            buffer.clear();
            discardMap.clear();
            
            buffer.notifyAll();
          }
        }
        if (events != null) {
          for (int i = 0; i < events.length; i++) {
            synchronized (appenders)
            {
              appenders.appendLoopOnAppenders(events[i]);
            }
          }
        }
      }
    }
    catch (InterruptedException ex)
    {
      Thread.currentThread().interrupt();
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.AsyncAppender.Dispatcher
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.log4j.helpers.AppenderAttachableImpl;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.spi.AppenderAttachable;
import org.apache.log4j.spi.LoggingEvent;

public class AsyncAppender
  extends AppenderSkeleton
  implements AppenderAttachable
{
  public static final int DEFAULT_BUFFER_SIZE = 128;
  private final List buffer = new ArrayList();
  private final Map discardMap = new HashMap();
  private int bufferSize = 128;
  AppenderAttachableImpl aai;
  private final AppenderAttachableImpl appenders;
  private final Thread dispatcher;
  private boolean locationInfo = false;
  private boolean blocking = true;
  
  public AsyncAppender()
  {
    appenders = new AppenderAttachableImpl();
    
    aai = appenders;
    
    dispatcher = new Thread(new Dispatcher(this, buffer, discardMap, appenders));
    
    dispatcher.setDaemon(true);
    
    dispatcher.setName("Dispatcher-" + dispatcher.getName());
    dispatcher.start();
  }
  
  public void addAppender(Appender newAppender)
  {
    synchronized (appenders)
    {
      appenders.addAppender(newAppender);
    }
  }
  
  public void append(LoggingEvent event)
  {
    if ((dispatcher == null) || (!dispatcher.isAlive()) || (bufferSize <= 0))
    {
      synchronized (appenders)
      {
        appenders.appendLoopOnAppenders(event);
      }
      return;
    }
    event.getNDC();
    event.getThreadName();
    
    event.getMDCCopy();
    if (locationInfo) {
      event.getLocationInformation();
    }
    synchronized (buffer)
    {
      for (;;)
      {
        int previousSize = buffer.size();
        if (previousSize < bufferSize)
        {
          buffer.add(event);
          if (previousSize != 0) {
            break;
          }
          buffer.notifyAll(); break;
        }
        boolean discard = true;
        if ((blocking) && (!Thread.interrupted()) && (Thread.currentThread() != dispatcher)) {
          try
          {
            buffer.wait();
            discard = false;
          }
          catch (InterruptedException e)
          {
            Thread.currentThread().interrupt();
          }
        }
        if (discard)
        {
          String loggerName = event.getLoggerName();
          DiscardSummary summary = (DiscardSummary)discardMap.get(loggerName);
          if (summary == null)
          {
            summary = new DiscardSummary(event);
            discardMap.put(loggerName, summary); break;
          }
          summary.add(event);
          
          break;
        }
      }
    }
  }
  
  public void close()
  {
    synchronized (buffer)
    {
      closed = true;
      buffer.notifyAll();
    }
    try
    {
      dispatcher.join();
    }
    catch (InterruptedException localObject1)
    {
      Thread.currentThread().interrupt();
      LogLog.error("Got an InterruptedException while waiting for the dispatcher to finish.", (Throwable)???);
    }
    synchronized (appenders)
    {
      Enumeration iter = appenders.getAllAppenders();
      if (iter != null) {
        while (iter.hasMoreElements())
        {
          Object next = iter.nextElement();
          if ((next instanceof Appender)) {
            ((Appender)next).close();
          }
        }
      }
    }
  }
  
  public Enumeration getAllAppenders()
  {
    synchronized (appenders)
    {
      Enumeration localEnumeration = appenders.getAllAppenders();return localEnumeration;
    }
  }
  
  public Appender getAppender(String name)
  {
    synchronized (appenders)
    {
      Appender localAppender = appenders.getAppender(name);return localAppender;
    }
  }
  
  public boolean getLocationInfo()
  {
    return locationInfo;
  }
  
  public boolean isAttached(Appender appender)
  {
    synchronized (appenders)
    {
      boolean bool = appenders.isAttached(appender);return bool;
    }
  }
  
  public boolean requiresLayout()
  {
    return false;
  }
  
  public void removeAllAppenders()
  {
    synchronized (appenders)
    {
      appenders.removeAllAppenders();
    }
  }
  
  public void removeAppender(Appender appender)
  {
    synchronized (appenders)
    {
      appenders.removeAppender(appender);
    }
  }
  
  public void removeAppender(String name)
  {
    synchronized (appenders)
    {
      appenders.removeAppender(name);
    }
  }
  
  public void setLocationInfo(boolean flag)
  {
    locationInfo = flag;
  }
  
  public void setBufferSize(int size)
  {
    if (size < 0) {
      throw new NegativeArraySizeException("size");
    }
    synchronized (buffer)
    {
      bufferSize = (size < 1 ? 1 : size);
      buffer.notifyAll();
    }
  }
  
  public int getBufferSize()
  {
    return bufferSize;
  }
  
  public void setBlocking(boolean value)
  {
    synchronized (buffer)
    {
      blocking = value;
      buffer.notifyAll();
    }
  }
  
  public boolean getBlocking()
  {
    return blocking;
  }
  
  private static final class DiscardSummary
  {
    private LoggingEvent maxEvent;
    private int count;
    
    public DiscardSummary(LoggingEvent event)
    {
      maxEvent = event;
      count = 1;
    }
    
    public void add(LoggingEvent event)
    {
      if (event.getLevel().toInt() > maxEvent.getLevel().toInt()) {
        maxEvent = event;
      }
      count += 1;
    }
    
    public LoggingEvent createEvent()
    {
      String msg = MessageFormat.format("Discarded {0} messages due to full event buffer including: {1}", new Object[] { new Integer(count), maxEvent.getMessage() });
      
      return new LoggingEvent(null, Logger.getLogger(maxEvent.getLoggerName()), maxEvent.getLevel(), msg, null);
    }
  }
  
  private static class Dispatcher
    implements Runnable
  {
    private final AsyncAppender parent;
    private final List buffer;
    private final Map discardMap;
    private final AppenderAttachableImpl appenders;
    
    public Dispatcher(AsyncAppender parent, List buffer, Map discardMap, AppenderAttachableImpl appenders)
    {
      this.parent = parent;
      this.buffer = buffer;
      this.appenders = appenders;
      this.discardMap = discardMap;
    }
    
    public void run()
    {
      boolean isActive = true;
      try
      {
        while (isActive)
        {
          LoggingEvent[] events = null;
          synchronized (buffer)
          {
            int bufferSize = buffer.size();
            isActive = !parent.closed;
            while ((bufferSize == 0) && (isActive))
            {
              buffer.wait();
              bufferSize = buffer.size();
              isActive = !parent.closed;
            }
            if (bufferSize > 0)
            {
              events = new LoggingEvent[bufferSize + discardMap.size()];
              buffer.toArray(events);
              
              ??? = bufferSize;
              
              Iterator iter = discardMap.values().iterator();
              while (iter.hasNext()) {
                events[(???++)] = ((AsyncAppender.DiscardSummary)iter.next()).createEvent();
              }
              buffer.clear();
              discardMap.clear();
              
              buffer.notifyAll();
            }
          }
          if (events != null) {
            for (int i = 0; i < events.length; i++) {
              synchronized (appenders)
              {
                appenders.appendLoopOnAppenders(events[i]);
              }
            }
          }
        }
      }
      catch (InterruptedException ex)
      {
        Thread.currentThread().interrupt();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.AsyncAppender
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

public class BasicConfigurator
{
  public static void configure()
  {
    Logger root = Logger.getRootLogger();
    root.addAppender(new ConsoleAppender(new PatternLayout("%r [%t] %p %c %x - %m%n")));
  }
  
  public static void configure(Appender appender)
  {
    Logger root = Logger.getRootLogger();
    root.addAppender(appender);
  }
  
  public static void resetConfiguration() {}
}

/* Location:
 * Qualified Name:     org.apache.log4j.BasicConfigurator
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.log4j.helpers.AppenderAttachableImpl;
import org.apache.log4j.helpers.NullEnumeration;
import org.apache.log4j.spi.AppenderAttachable;
import org.apache.log4j.spi.LoggerRepository;
import org.apache.log4j.spi.LoggingEvent;

public class Category
  implements AppenderAttachable
{
  protected String name;
  protected volatile Level level;
  protected volatile Category parent;
  private static final String FQCN = Category.class.getName();
  protected ResourceBundle resourceBundle;
  protected LoggerRepository repository;
  AppenderAttachableImpl aai;
  protected boolean additive = true;
  
  protected Category(String name)
  {
    this.name = name;
  }
  
  public synchronized void addAppender(Appender newAppender)
  {
    if (aai == null) {
      aai = new AppenderAttachableImpl();
    }
    aai.addAppender(newAppender);
    repository.fireAddAppenderEvent(this, newAppender);
  }
  
  public void assertLog(boolean assertion, String msg)
  {
    if (!assertion) {
      error(msg);
    }
  }
  
  public void callAppenders(LoggingEvent event)
  {
    int writes = 0;
    for (Category c = this; c != null; c = parent) {
      synchronized (c)
      {
        if (aai != null) {
          writes += aai.appendLoopOnAppenders(event);
        }
        if (!additive) {
          break;
        }
      }
    }
    if (writes == 0) {
      repository.emitNoAppenderWarning(this);
    }
  }
  
  synchronized void closeNestedAppenders()
  {
    Enumeration enumeration = getAllAppenders();
    if (enumeration != null) {
      while (enumeration.hasMoreElements())
      {
        Appender a = (Appender)enumeration.nextElement();
        if ((a instanceof AppenderAttachable)) {
          a.close();
        }
      }
    }
  }
  
  public void debug(Object message)
  {
    if (repository.isDisabled(10000)) {
      return;
    }
    if (Level.DEBUG.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.DEBUG, message, null);
    }
  }
  
  public void debug(Object message, Throwable t)
  {
    if (repository.isDisabled(10000)) {
      return;
    }
    if (Level.DEBUG.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.DEBUG, message, t);
    }
  }
  
  public void error(Object message)
  {
    if (repository.isDisabled(40000)) {
      return;
    }
    if (Level.ERROR.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.ERROR, message, null);
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (repository.isDisabled(40000)) {
      return;
    }
    if (Level.ERROR.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.ERROR, message, t);
    }
  }
  
  /**
   * @deprecated
   */
  public static Logger exists(String name)
  {
    return LogManager.exists(name);
  }
  
  public void fatal(Object message)
  {
    if (repository.isDisabled(50000)) {
      return;
    }
    if (Level.FATAL.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.FATAL, message, null);
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (repository.isDisabled(50000)) {
      return;
    }
    if (Level.FATAL.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.FATAL, message, t);
    }
  }
  
  protected void forcedLog(String fqcn, Priority level, Object message, Throwable t)
  {
    callAppenders(new LoggingEvent(fqcn, this, level, message, t));
  }
  
  public boolean getAdditivity()
  {
    return additive;
  }
  
  public synchronized Enumeration getAllAppenders()
  {
    if (aai == null) {
      return NullEnumeration.getInstance();
    }
    return aai.getAllAppenders();
  }
  
  public synchronized Appender getAppender(String name)
  {
    if ((aai == null) || (name == null)) {
      return null;
    }
    return aai.getAppender(name);
  }
  
  public Level getEffectiveLevel()
  {
    for (Category c = this; c != null; c = parent) {
      if (level != null) {
        return level;
      }
    }
    return null;
  }
  
  /**
   * @deprecated
   */
  public Priority getChainedPriority()
  {
    for (Category c = this; c != null; c = parent) {
      if (level != null) {
        return level;
      }
    }
    return null;
  }
  
  /**
   * @deprecated
   */
  public static Enumeration getCurrentCategories()
  {
    return LogManager.getCurrentLoggers();
  }
  
  /**
   * @deprecated
   */
  public static LoggerRepository getDefaultHierarchy()
  {
    return LogManager.getLoggerRepository();
  }
  
  /**
   * @deprecated
   */
  public LoggerRepository getHierarchy()
  {
    return repository;
  }
  
  public LoggerRepository getLoggerRepository()
  {
    return repository;
  }
  
  /**
   * @deprecated
   */
  public static Category getInstance(String name)
  {
    return LogManager.getLogger(name);
  }
  
  /**
   * @deprecated
   */
  public static Category getInstance(Class clazz)
  {
    return LogManager.getLogger(clazz);
  }
  
  public final String getName()
  {
    return name;
  }
  
  public final Category getParent()
  {
    return parent;
  }
  
  public final Level getLevel()
  {
    return level;
  }
  
  /**
   * @deprecated
   */
  public final Level getPriority()
  {
    return level;
  }
  
  /**
   * @deprecated
   */
  public static final Category getRoot()
  {
    return LogManager.getRootLogger();
  }
  
  public ResourceBundle getResourceBundle()
  {
    for (Category c = this; c != null; c = parent) {
      if (resourceBundle != null) {
        return resourceBundle;
      }
    }
    return null;
  }
  
  protected String getResourceBundleString(String key)
  {
    ResourceBundle rb = getResourceBundle();
    if (rb == null) {
      return null;
    }
    try
    {
      return rb.getString(key);
    }
    catch (MissingResourceException mre)
    {
      error("No resource is associated with key \"" + key + "\".");
    }
    return null;
  }
  
  public void info(Object message)
  {
    if (repository.isDisabled(20000)) {
      return;
    }
    if (Level.INFO.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.INFO, message, null);
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (repository.isDisabled(20000)) {
      return;
    }
    if (Level.INFO.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.INFO, message, t);
    }
  }
  
  public boolean isAttached(Appender appender)
  {
    if ((appender == null) || (aai == null)) {
      return false;
    }
    return aai.isAttached(appender);
  }
  
  public boolean isDebugEnabled()
  {
    if (repository.isDisabled(10000)) {
      return false;
    }
    return Level.DEBUG.isGreaterOrEqual(getEffectiveLevel());
  }
  
  public boolean isEnabledFor(Priority level)
  {
    if (repository.isDisabled(level)) {
      return false;
    }
    return level.isGreaterOrEqual(getEffectiveLevel());
  }
  
  public boolean isInfoEnabled()
  {
    if (repository.isDisabled(20000)) {
      return false;
    }
    return Level.INFO.isGreaterOrEqual(getEffectiveLevel());
  }
  
  public void l7dlog(Priority priority, String key, Throwable t)
  {
    if (repository.isDisabled(level)) {
      return;
    }
    if (priority.isGreaterOrEqual(getEffectiveLevel()))
    {
      String msg = getResourceBundleString(key);
      if (msg == null) {
        msg = key;
      }
      forcedLog(FQCN, priority, msg, t);
    }
  }
  
  public void l7dlog(Priority priority, String key, Object[] params, Throwable t)
  {
    if (repository.isDisabled(level)) {
      return;
    }
    if (priority.isGreaterOrEqual(getEffectiveLevel()))
    {
      String pattern = getResourceBundleString(key);
      String msg;
      if (pattern == null) {
        msg = key;
      } else {
        msg = MessageFormat.format(pattern, params);
      }
      forcedLog(FQCN, priority, msg, t);
    }
  }
  
  public void log(Priority priority, Object message, Throwable t)
  {
    if (repository.isDisabled(level)) {
      return;
    }
    if (priority.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, priority, message, t);
    }
  }
  
  public void log(Priority priority, Object message)
  {
    if (repository.isDisabled(level)) {
      return;
    }
    if (priority.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, priority, message, null);
    }
  }
  
  public void log(String callerFQCN, Priority level, Object message, Throwable t)
  {
    if (repository.isDisabled(level)) {
      return;
    }
    if (level.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(callerFQCN, level, message, t);
    }
  }
  
  public synchronized void removeAllAppenders()
  {
    if (aai != null)
    {
      aai.removeAllAppenders();
      aai = null;
    }
  }
  
  public synchronized void removeAppender(Appender appender)
  {
    if ((appender == null) || (aai == null)) {
      return;
    }
    aai.removeAppender(appender);
  }
  
  public synchronized void removeAppender(String name)
  {
    if ((name == null) || (aai == null)) {
      return;
    }
    aai.removeAppender(name);
  }
  
  public void setAdditivity(boolean additive)
  {
    this.additive = additive;
  }
  
  final void setHierarchy(LoggerRepository repository)
  {
    this.repository = repository;
  }
  
  public void setLevel(Level level)
  {
    this.level = level;
  }
  
  /**
   * @deprecated
   */
  public void setPriority(Priority priority)
  {
    level = ((Level)priority);
  }
  
  public void setResourceBundle(ResourceBundle bundle)
  {
    resourceBundle = bundle;
  }
  
  /**
   * @deprecated
   */
  public static void shutdown() {}
  
  public void warn(Object message)
  {
    if (repository.isDisabled(30000)) {
      return;
    }
    if (Level.WARN.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.WARN, message, null);
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (repository.isDisabled(30000)) {
      return;
    }
    if (Level.WARN.isGreaterOrEqual(getEffectiveLevel())) {
      forcedLog(FQCN, Level.WARN, message, t);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.Category
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

class CategoryKey
{
  String name;
  int hashCache;
  
  CategoryKey(String name)
  {
    this.name = name;
    hashCache = name.hashCode();
  }
  
  public final int hashCode()
  {
    return hashCache;
  }
  
  public final boolean equals(Object rArg)
  {
    if (this == rArg) {
      return true;
    }
    if ((rArg != null) && (CategoryKey.class == rArg.getClass())) {
      return name.equals(name);
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.CategoryKey
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

class ConsoleAppender$SystemErrStream
  extends OutputStream
{
  public void close() {}
  
  public void flush()
  {
    System.err.flush();
  }
  
  public void write(byte[] b)
    throws IOException
  {
    System.err.write(b);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    System.err.write(b, off, len);
  }
  
  public void write(int b)
    throws IOException
  {
    System.err.write(b);
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.ConsoleAppender.SystemErrStream
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

class ConsoleAppender$SystemOutStream
  extends OutputStream
{
  public void close() {}
  
  public void flush()
  {
    System.out.flush();
  }
  
  public void write(byte[] b)
    throws IOException
  {
    System.out.write(b);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    System.out.write(b, off, len);
  }
  
  public void write(int b)
    throws IOException
  {
    System.out.write(b);
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.ConsoleAppender.SystemOutStream
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.log4j.helpers.LogLog;

public class ConsoleAppender
  extends WriterAppender
{
  public static final String SYSTEM_OUT = "System.out";
  public static final String SYSTEM_ERR = "System.err";
  protected String target = "System.out";
  private boolean follow = false;
  
  public ConsoleAppender() {}
  
  public ConsoleAppender(Layout layout)
  {
    this(layout, "System.out");
  }
  
  public ConsoleAppender(Layout layout, String target)
  {
    setLayout(layout);
    setTarget(target);
    activateOptions();
  }
  
  public void setTarget(String value)
  {
    String v = value.trim();
    if ("System.out".equalsIgnoreCase(v)) {
      target = "System.out";
    } else if ("System.err".equalsIgnoreCase(v)) {
      target = "System.err";
    } else {
      targetWarn(value);
    }
  }
  
  public String getTarget()
  {
    return target;
  }
  
  public final void setFollow(boolean newValue)
  {
    follow = newValue;
  }
  
  public final boolean getFollow()
  {
    return follow;
  }
  
  void targetWarn(String val)
  {
    LogLog.warn("[" + val + "] should be System.out or System.err.");
    LogLog.warn("Using previously set target, System.out by default.");
  }
  
  public void activateOptions()
  {
    if (follow)
    {
      if (target.equals("System.err")) {
        setWriter(createWriter(new SystemErrStream()));
      } else {
        setWriter(createWriter(new SystemOutStream()));
      }
    }
    else if (target.equals("System.err")) {
      setWriter(createWriter(System.err));
    } else {
      setWriter(createWriter(System.out));
    }
    super.activateOptions();
  }
  
  protected final void closeWriter()
  {
    if (follow) {
      super.closeWriter();
    }
  }
  
  private static class SystemErrStream
    extends OutputStream
  {
    public void close() {}
    
    public void flush()
    {
      System.err.flush();
    }
    
    public void write(byte[] b)
      throws IOException
    {
      System.err.write(b);
    }
    
    public void write(byte[] b, int off, int len)
      throws IOException
    {
      System.err.write(b, off, len);
    }
    
    public void write(int b)
      throws IOException
    {
      System.err.write(b);
    }
  }
  
  private static class SystemOutStream
    extends OutputStream
  {
    public void close() {}
    
    public void flush()
    {
      System.out.flush();
    }
    
    public void write(byte[] b)
      throws IOException
    {
      System.out.write(b);
    }
    
    public void write(byte[] b, int off, int len)
      throws IOException
    {
      System.out.write(b, off, len);
    }
    
    public void write(int b)
      throws IOException
    {
      System.out.write(b);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.ConsoleAppender
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.spi.ErrorHandler;
import org.apache.log4j.spi.LoggingEvent;

public class DailyRollingFileAppender
  extends FileAppender
{
  static final int TOP_OF_TROUBLE = -1;
  static final int TOP_OF_MINUTE = 0;
  static final int TOP_OF_HOUR = 1;
  static final int HALF_DAY = 2;
  static final int TOP_OF_DAY = 3;
  static final int TOP_OF_WEEK = 4;
  static final int TOP_OF_MONTH = 5;
  private String datePattern = "'.'yyyy-MM-dd";
  private String scheduledFilename;
  private long nextCheck = System.currentTimeMillis() - 1L;
  Date now = new Date();
  SimpleDateFormat sdf;
  RollingCalendar rc = new RollingCalendar();
  int checkPeriod = -1;
  static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
  
  public DailyRollingFileAppender() {}
  
  public DailyRollingFileAppender(Layout layout, String filename, String datePattern)
    throws IOException
  {
    super(layout, filename, true);
    this.datePattern = datePattern;
    activateOptions();
  }
  
  public void setDatePattern(String pattern)
  {
    datePattern = pattern;
  }
  
  public String getDatePattern()
  {
    return datePattern;
  }
  
  public void activateOptions()
  {
    super.activateOptions();
    if ((datePattern != null) && (fileName != null))
    {
      now.setTime(System.currentTimeMillis());
      sdf = new SimpleDateFormat(datePattern);
      int type = computeCheckPeriod();
      printPeriodicity(type);
      rc.setType(type);
      File file = new File(fileName);
      scheduledFilename = (fileName + sdf.format(new Date(file.lastModified())));
    }
    else
    {
      LogLog.error("Either File or DatePattern options are not set for appender [" + name + "].");
    }
  }
  
  void printPeriodicity(int type)
  {
    switch (type)
    {
    case 0: 
      LogLog.debug("Appender [" + name + "] to be rolled every minute.");
      break;
    case 1: 
      LogLog.debug("Appender [" + name + "] to be rolled on top of every hour.");
      
      break;
    case 2: 
      LogLog.debug("Appender [" + name + "] to be rolled at midday and midnight.");
      
      break;
    case 3: 
      LogLog.debug("Appender [" + name + "] to be rolled at midnight.");
      
      break;
    case 4: 
      LogLog.debug("Appender [" + name + "] to be rolled at start of week.");
      
      break;
    case 5: 
      LogLog.debug("Appender [" + name + "] to be rolled at start of every month.");
      
      break;
    default: 
      LogLog.warn("Unknown periodicity for appender [" + name + "].");
    }
  }
  
  int computeCheckPeriod()
  {
    RollingCalendar rollingCalendar = new RollingCalendar(gmtTimeZone, Locale.ENGLISH);
    
    Date epoch = new Date(0L);
    if (datePattern != null) {
      for (int i = 0; i <= 5; i++)
      {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datePattern);
        simpleDateFormat.setTimeZone(gmtTimeZone);
        String r0 = simpleDateFormat.format(epoch);
        rollingCalendar.setType(i);
        Date next = new Date(rollingCalendar.getNextCheckMillis(epoch));
        String r1 = simpleDateFormat.format(next);
        if ((r0 != null) && (r1 != null) && (!r0.equals(r1))) {
          return i;
        }
      }
    }
    return -1;
  }
  
  void rollOver()
    throws IOException
  {
    if (datePattern == null)
    {
      errorHandler.error("Missing DatePattern option in rollOver().");
      return;
    }
    String datedFilename = fileName + sdf.format(now);
    if (scheduledFilename.equals(datedFilename)) {
      return;
    }
    closeFile();
    
    File target = new File(scheduledFilename);
    if (target.exists()) {
      target.delete();
    }
    File file = new File(fileName);
    boolean result = file.renameTo(target);
    if (result) {
      LogLog.debug(fileName + " -> " + scheduledFilename);
    } else {
      LogLog.error("Failed to rename [" + fileName + "] to [" + scheduledFilename + "].");
    }
    try
    {
      setFile(fileName, false, bufferedIO, bufferSize);
    }
    catch (IOException e)
    {
      errorHandler.error("setFile(" + fileName + ", false) call failed.");
    }
    scheduledFilename = datedFilename;
  }
  
  protected void subAppend(LoggingEvent event)
  {
    long n = System.currentTimeMillis();
    if (n >= nextCheck)
    {
      now.setTime(n);
      nextCheck = rc.getNextCheckMillis(now);
      try
      {
        rollOver();
      }
      catch (IOException ioe)
      {
        LogLog.error("rollOver() failed.", ioe);
      }
    }
    super.subAppend(event);
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.DailyRollingFileAppender
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import org.apache.log4j.spi.LoggerFactory;

class DefaultCategoryFactory
  implements LoggerFactory
{
  public Logger makeNewLoggerInstance(String name)
  {
    return new Logger(name);
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.DefaultCategoryFactory
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import org.apache.log4j.helpers.AppenderAttachableImpl;
import org.apache.log4j.helpers.BoundedFIFO;
import org.apache.log4j.spi.LoggingEvent;

/**
 * @deprecated
 */
class Dispatcher
  extends Thread
{
  /**
   * @deprecated
   */
  private BoundedFIFO bf;
  private AppenderAttachableImpl aai;
  private boolean interrupted = false;
  AsyncAppender container;
  
  /**
   * @deprecated
   */
  Dispatcher(BoundedFIFO bf, AsyncAppender container)
  {
    this.bf = bf;
    this.container = container;
    aai = aai;
    
    setDaemon(true);
    
    setPriority(1);
    setName("Dispatcher-" + getName());
  }
  
  void close()
  {
    synchronized (bf)
    {
      interrupted = true;
      if (bf.length() == 0) {
        bf.notify();
      }
    }
  }
  
  public void run()
  {
    for (;;)
    {
      LoggingEvent event;
      synchronized (bf)
      {
        if (bf.length() == 0)
        {
          if (interrupted) {
            break;
          }
          try
          {
            bf.wait();
          }
          catch (InterruptedException ???)
          {
            break;
          }
        }
        event = bf.get();
        if (bf.wasFull()) {
          bf.notify();
        }
      }
      synchronized (container.aai)
      {
        if ((aai != null) && (event != null)) {
          aai.appendLoopOnAppenders(event);
        }
      }
    }
    aai.removeAllAppenders();
  }
}

/* Location:
 * Qualified Name:     org.apache.log4j.Dispatcher
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.log4j;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterWriter;
import java.io.IOException;
import java.io.Writer;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.helpers.QuietWriter;
import org.apache.log4j.spi.ErrorHandler;

public class FileAppender
  extends WriterAppender
{
  protected boolean fileAppend = true;
  protected String fileName = null;
  protected boolean bufferedIO = false;
  protected int bufferSize = 8192;
  
  public FileAppender() {}
  
  public FileAppender(Layout layout, String filename, boolean append, boolean bufferedIO, int bufferSize)
    throws IOException
  {
    this.layout = layout;
    setFile(filename, append, bufferedIO, bufferSize);
  }
  
  public FileAppender(Layout layout, String filename, boolean append)
    throws IOException
  {
    this.layout = layout;
    setFile(filename, append, false, bufferSize);
  }
  
  public FileAppender(Layout layout, String filename)
    throws IOException
  {
    this(layout, filename, true);
  }
  
  public void setFile(String file)
  {
    String val = file.trim();
    fileName = val;
  }
  
  public boolean getAppend()
  {
    return fileAppend;
  }
  
  public String getFile()
  {
    return fileName;
  }
  
  public void activateOptions()
  {
    if (fileName != null)
    {
      try
      {
        setFile(fileName, fileAppend, bufferedIO, bufferSize);
      }
      catch (IOException e)
      {
        errorHandler.error("setFile(" + fileName + "," + fileAppend + ") call failed.", e, 4);
      }
    }
    else
    {
      LogLog.warn("File option not set for appender [" + name + "].");
      LogLog.warn("Are you using FileAppender instead of ConsoleAppender?");
    }
  }
  
  protected void closeFile()
  {
    if (qw != null) {
      try
      {
        qw.close();
      }
      catch (IOException e)
      {
        LogLog.error("Could not close " + qw, e);
      }
    }
  }
  
  public boolean getBufferedIO()
  {
    return bufferedIO;
  }
  
  public int getBufferSize()
  {
    return bufferSize;
  }
  
  public void setAppend(boolean flag)
  {
    fileAppend = flag;
  }
  
  public void setBufferedIO(boolean bufferedIO)
  {
    this.bufferedIO = bufferedIO;
    if (bufferedIO) {
      immediateFlush = fa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd