mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
06.51.2014 10bac0ad21fca0c5ac8bf6d7dc712c5899c2d0e6
Fix OPENDJ-1289 Runtime debug configuration changes have no effect

* No need to restart the server to enable debug logging
* Replace static methods to add/remove log publishers in AccessLogger,
DebugLogger, ErrorLogger and HTTPAccessLogger by instance methods
in order to have a single way to add a publisher
* Encapsulate loggerStorage instance variable
* Replace static calls to DebugLogger by debugLogger.getInstance()
20 files modified
585 ■■■■ changed files
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/DebugLogPublisherConfiguration.xml 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java 25 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractLogger.java 41 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/AccessLogger.java 53 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/ActionType.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugLogger.java 85 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugStackTraceFormatter.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugTracer.java 154 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/ErrorLogger.java 62 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/HTTPAccessLogger.java 65 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPConnection.java 12 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java 5 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java 27 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/DebugLogPublisherConfiguration.xml
@@ -57,8 +57,8 @@
    </adm:profile>
    <adm:profile name="cli">
      <cli:relation>
        <cli:default-property name="debug-level" />
        <cli:default-property name="debug-category" />
        <cli:default-property name="enabled" />
        <cli:default-property name="debug-exceptions-only" />
      </cli:relation>
    </adm:profile>
  </adm:relation>
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -30,9 +30,6 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.loggers.DebugLogger.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.DynamicConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -8100,9 +8097,9 @@
    // loggers.
    logger.info(NOTE_SERVER_STOPPED.get());
    removeAllAccessLogPublishers();
    removeAllErrorLogPublishers();
    removeAllDebugLogPublishers();
    AccessLogger.getInstance().removeAllLogPublishers();
    ErrorLogger.getInstance().removeAllLogPublishers();
    DebugLogger.getInstance().removeAllLogPublishers();
    // Now that the loggers are disabled we can shutdown the timer.
    TimeThread.stop();
@@ -9186,18 +9183,16 @@
                         "standard error:  " + stackTraceToSingleLineString(e));
    }
    // Install the default loggers so the startup messages
    // will be printed.
    TextErrorLogPublisher startupErrorLogPublisher =
    ErrorLogPublisher startupErrorLogPublisher =
        TextErrorLogPublisher.getServerStartupTextErrorPublisher(
            new TextWriter.STDOUT());
    ErrorLogger.addErrorLogPublisher(startupErrorLogPublisher);
    ErrorLogger.getInstance().addLogPublisher(startupErrorLogPublisher);
    TextDebugLogPublisher startupDebugLogPublisher =
        TextDebugLogPublisher.getStartupTextDebugPublisher(
            new TextWriter.STDOUT());
    DebugLogger.addDebugLogPublisher(startupDebugLogPublisher);
    DebugLogPublisher startupDebugLogPublisher =
        TextDebugLogPublisher.getStartupTextDebugPublisher(new TextWriter.STDOUT());
    DebugLogger.getInstance().addLogPublisher(startupDebugLogPublisher);
    // Create an environment configuration for the server and populate a number
@@ -9271,8 +9266,8 @@
      shutDown(theDirectoryServer.getClass().getName(), message);
    }
    ErrorLogger.removeErrorLogPublisher(startupErrorLogPublisher);
    DebugLogger.removeDebugLogPublisher(startupDebugLogPublisher);
    ErrorLogger.getInstance().removeLogPublisher(startupErrorLogPublisher);
    DebugLogger.getInstance().removeLogPublisher(startupDebugLogPublisher);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractLogger.java
@@ -147,11 +147,33 @@
  }
  /**
   * Returns the logger storage for the current logger.
   * Returns the log publishers.
   *
   * @return the logger storage for the current logger
   * @return the collection of {@link LogPublisher}s
   */
  protected abstract LoggerStorage<P, C> getStorage();
  protected abstract Collection<P> getLogPublishers();
  /**
   * Add a log publisher to the logger.
   *
   * @param publisher
   *          The log publisher to add.
   */
  public abstract void addLogPublisher(P publisher);
  /**
   * Remove a log publisher from the logger.
   *
   * @param publisher
   *          The log publisher to remove.
   * @return True if the log publisher is removed or false otherwise.
   */
  public abstract boolean removeLogPublisher(P publisher);
  /**
   * Removes all existing log publishers from the logger.
   */
  public abstract void removeAllLogPublishers();
  /**
   * Returns the java {@link ClassPropertyDefinition} for the current logger.
@@ -175,7 +197,7 @@
   * @param invalidLoggerClassErrorMessage
   *          the error message to use if the logger class in invalid
   */
  public AbstractLogger(
  AbstractLogger(
      final Class<P> logPublisherClass,
      final Arg3<Object, Object, Object>
          invalidLoggerClassErrorMessage)
@@ -208,7 +230,7 @@
      if(config.isEnabled())
      {
        getStorage().addLogPublisher(getLogPublisher(config));
        addLogPublisher(getLogPublisher(config));
      }
    }
  }
@@ -252,7 +274,7 @@
    {
      try
      {
        getStorage().addLogPublisher(getLogPublisher(config));
        addLogPublisher(getLogPublisher(config));
      }
      catch(ConfigException e)
      {
@@ -273,8 +295,7 @@
  private P findLogPublisher(DN dn)
  {
    Collection<P> logPublishers = getStorage().getLogPublishers();
    for (P publisher : logPublishers)
    for (P publisher : getLogPublishers())
    {
      if (publisher.getDN().equals(dn))
      {
@@ -322,7 +343,7 @@
      else
      {
        // The publisher is being disabled so shut down and remove.
        getStorage().removeLogPublisher(logPublisher);
        removeLogPublisher(logPublisher);
      }
    }
@@ -352,7 +373,7 @@
    P logPublisher = findLogPublisher(config.dn());
    if(logPublisher != null)
    {
      getStorage().removeLogPublisher(logPublisher);
      removeLogPublisher(logPublisher);
    }
    else
    {
opendj3-server-dev/src/server/org/opends/server/loggers/AccessLogger.java
@@ -52,13 +52,13 @@
      loggerStorage = new LoggerStorage
      <AccessLogPublisher<AccessLogPublisherCfg>, AccessLogPublisherCfg>();
  /** The singleton instance of this class for configuration purposes. */
  /** The singleton instance of this class. */
  private static final AccessLogger instance = new AccessLogger();
  /**
   * The constructor for this class.
   */
  public AccessLogger()
  private AccessLogger()
  {
    super((Class) AccessLogPublisher.class,
        ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS);
@@ -74,10 +74,9 @@
  /** {@inheritDoc} */
  @Override
  protected LoggerStorage<AccessLogPublisher<AccessLogPublisherCfg>,
      AccessLogPublisherCfg> getStorage()
  protected Collection<AccessLogPublisher<AccessLogPublisherCfg>> getLogPublishers()
  {
    return loggerStorage;
    return loggerStorage.getLogPublishers();
  }
  /**
@@ -90,28 +89,7 @@
    return instance;
  }
  /**
   * Add an access log publisher to the access logger.
   *
   * @param publisher The access log publisher to add.
   */
  public synchronized static void addAccessLogPublisher(
      AccessLogPublisher publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /**
   * Remove an access log publisher from the access logger.
   *
   * @param publisher The access log publisher to remove.
   * @return The publisher that was removed or null if it was not found.
   */
  public synchronized static boolean removeAccessLogPublisher(
      AccessLogPublisher<AccessLogPublisherCfg> publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /**
   * Removes all existing access log publishers from the logger.
@@ -532,5 +510,28 @@
      publisher.logUnbind(unbindOperation);
    }
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void addLogPublisher(
      AccessLogPublisher<AccessLogPublisherCfg> publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized boolean removeLogPublisher(
      AccessLogPublisher<AccessLogPublisherCfg> publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void removeAllLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/ActionType.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -30,7 +31,7 @@
/**
 * This enumeration defines the post rotation actions possible.
 */
public enum ActionType
enum ActionType
{
  /**
   * The action type that indicates the rotated file should be compressed using
opendj3-server-dev/src/server/org/opends/server/loggers/DebugLogger.java
@@ -28,6 +28,7 @@
import static org.opends.messages.ConfigMessages.*;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -67,13 +68,13 @@
      loggerStorage = new LoggerStorage
      <DebugLogPublisher<DebugLogPublisherCfg>, DebugLogPublisherCfg>();
  /** The singleton instance of this class for configuration purposes. */
  /** The singleton instance of this class. */
  static final DebugLogger instance = new DebugLogger();
  /**
   * The constructor for this class.
   */
  public DebugLogger()
  private DebugLogger()
  {
    super((Class) DebugLogPublisher.class,
        ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS);
@@ -89,55 +90,9 @@
  /** {@inheritDoc} */
  @Override
  protected LoggerStorage<DebugLogPublisher<DebugLogPublisherCfg>,
      DebugLogPublisherCfg> getStorage()
  protected Collection<DebugLogPublisher<DebugLogPublisherCfg>> getLogPublishers()
  {
    return loggerStorage;
  }
  /**
   * Add an debug log publisher to the debug logger.
   *
   * @param publisher The debug log publisher to add.
   */
  public synchronized static void addDebugLogPublisher(
      DebugLogPublisher publisher)
  {
    loggerStorage.addLogPublisher(publisher);
    updateTracerSettings();
    enabled = true;
  }
  /**
   * Remove an debug log publisher from the debug logger.
   *
   * @param publisher The debug log publisher to remove.
   * @return The publisher that was removed or null if it was not found.
   */
  public synchronized static boolean removeDebugLogPublisher(
      DebugLogPublisher publisher)
  {
    boolean removed = loggerStorage.removeLogPublisher(publisher);
    updateTracerSettings();
    enabled = !loggerStorage.getLogPublishers().isEmpty();
    return removed;
  }
  /**
   * Removes all existing debug log publishers from the logger.
   */
  public synchronized static void removeAllDebugLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
    updateTracerSettings();
    enabled = false;
    return loggerStorage.getLogPublishers();
  }
  /**
@@ -195,4 +150,34 @@
    return tracer;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void addLogPublisher(
      DebugLogPublisher<DebugLogPublisherCfg> publisher)
  {
    loggerStorage.addLogPublisher(publisher);
    updateTracerSettings();
    enabled = true;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized boolean removeLogPublisher(
      DebugLogPublisher<DebugLogPublisherCfg> publisher)
  {
    boolean removed = loggerStorage.removeLogPublisher(publisher);
    updateTracerSettings();
    enabled = !loggerStorage.getLogPublishers().isEmpty();
    return removed;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void removeAllLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
    updateTracerSettings();
    enabled = false;
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/DebugStackTraceFormatter.java
@@ -93,8 +93,7 @@
        // Skip leading frames debug logging classes
        while (firstFrame < frames.length &&
            isFrameForPackage(frames[firstFrame],
                              "org.opends.server.loggers.debug")) {
            DebugTracer.isLoggingStackTraceElement(frames[firstFrame])) {
          firstFrame++;
        }
opendj3-server-dev/src/server/org/opends/server/loggers/DebugTracer.java
@@ -111,83 +111,80 @@
   */
  void traceException(String msg, Throwable exception)
  {
    if(DebugLogger.debugEnabled())
    StackTraceElement[] stackTrace = null;
    StackTraceElement[] filteredStackTrace = null;
    StackTraceElement callerFrame = null;
    final boolean hasException = (exception != null);
    for (PublisherSettings settings : publisherSettings)
    {
      StackTraceElement[] stackTrace = null;
      StackTraceElement[] filteredStackTrace = null;
      StackTraceElement callerFrame = null;
      final boolean hasException = (exception != null);
      for (PublisherSettings settings : publisherSettings)
      TraceSettings activeSettings = settings.classSettings;
      Map<String, TraceSettings> methodSettings = settings.methodSettings;
      if (shouldLog(hasException, activeSettings) || methodSettings != null)
      {
        TraceSettings activeSettings = settings.classSettings;
        Map<String, TraceSettings> methodSettings = settings.methodSettings;
        if (shouldLog(hasException, activeSettings) || methodSettings != null)
        if (stackTrace == null)
        {
          if(stackTrace == null)
          {
            stackTrace = Thread.currentThread().getStackTrace();
          }
          if (callerFrame == null)
          {
            callerFrame = getCallerFrame(stackTrace);
          }
          stackTrace = Thread.currentThread().getStackTrace();
        }
        if (callerFrame == null)
        {
          callerFrame = getCallerFrame(stackTrace);
        }
          String signature = callerFrame.getMethodName();
        String signature = callerFrame.getMethodName();
          // Specific method settings still could exist. Try getting
          // the settings for this method.
          if(methodSettings != null)
        // Specific method settings still could exist. Try getting
        // the settings for this method.
        if (methodSettings != null)
        {
          TraceSettings mSettings = methodSettings.get(signature);
          if (mSettings == null)
          {
            TraceSettings mSettings = methodSettings.get(signature);
            if (mSettings == null)
            // Try looking for an undecorated method name
            int idx = signature.indexOf('(');
            if (idx != -1)
            {
              // Try looking for an undecorated method name
              int idx = signature.indexOf('(');
              if (idx != -1)
              {
                mSettings =
                    methodSettings.get(signature.substring(0, idx));
              }
            }
            // If this method does have a specific setting and it is not
            // suppose to be logged, continue.
            if (mSettings != null)
            {
              if(!shouldLog(hasException, mSettings))
              {
                continue;
              }
              else
              {
                activeSettings = mSettings;
              }
              mSettings = methodSettings.get(signature.substring(0, idx));
            }
          }
          String sourceLocation = callerFrame.getFileName() + ":" +
              callerFrame.getLineNumber();
          // If this method does have a specific setting and it is not
          // suppose to be logged, continue.
          if (mSettings != null)
          {
            if (!shouldLog(hasException, mSettings))
            {
              continue;
            }
            else
            {
              activeSettings = mSettings;
            }
          }
        }
          if (filteredStackTrace == null && activeSettings.getStackDepth() > 0)
          {
            StackTraceElement[] trace = hasException ? exception.getStackTrace() : stackTrace;
            filteredStackTrace =
                DebugStackTraceFormatter.SMART_FRAME_FILTER.
                    getFilteredStackTrace(trace);
          }
        String sourceLocation =
            callerFrame.getFileName() + ":" + callerFrame.getLineNumber();
          if (hasException)
          {
            settings.debugPublisher.traceException(activeSettings, signature,
                sourceLocation, msg, exception, filteredStackTrace);
          }
          else
          {
            settings.debugPublisher.trace(activeSettings, signature,
                sourceLocation, msg, filteredStackTrace);
          }
        if (filteredStackTrace == null && activeSettings.getStackDepth() > 0)
        {
          StackTraceElement[] trace =
              hasException ? exception.getStackTrace() : stackTrace;
          filteredStackTrace =
              DebugStackTraceFormatter.SMART_FRAME_FILTER
                  .getFilteredStackTrace(trace);
        }
        if (hasException)
        {
          settings.debugPublisher.traceException(activeSettings, signature,
              sourceLocation, msg, exception, filteredStackTrace);
        }
        else
        {
          settings.debugPublisher.trace(activeSettings, signature,
              sourceLocation, msg, filteredStackTrace);
        }
      }
    }
@@ -267,15 +264,10 @@
  {
    if (stackTrace != null && stackTrace.length > 0)
    {
      // Skip leading frames debug logging classes and getStackTrace
      // method call frame if any.
      // Skip all logging related classes
      for (StackTraceElement aStackTrace : stackTrace)
      {
        if(aStackTrace.getClassName().startsWith(Thread.class.getName()))
        {
          continue;
        }
        if (!aStackTrace.getClassName().startsWith(DebugTracer.class.getName()))
        if(!isLoggingStackTraceElement(aStackTrace))
        {
          return aStackTrace;
        }
@@ -285,6 +277,24 @@
    return null;
  }
  /**
   * Checks if element belongs to a class responsible for logging
   * (includes the Thread class that may be used to get the stack trace).
   *
   * @param trace
   *            the trace element to check.
   * @return {@code true} if element corresponds to logging
   */
  static boolean isLoggingStackTraceElement(StackTraceElement trace)
  {
    return false;
//    String name = trace.getClassName();
//    return name.startsWith(Thread.class.getName())
//        || name.startsWith(DebugTracer.class.getName())
//        || name.startsWith(OpenDJLoggerAdapter.class.getName())
//        || name.startsWith(LocalizedLogger.class.getName());
  }
  /** Indicates if there is something to log. */
  private boolean shouldLog(boolean hasException, TraceSettings activeSettings)
  {
opendj3-server-dev/src/server/org/opends/server/loggers/ErrorLogger.java
@@ -27,6 +27,7 @@
package org.opends.server.loggers;
import static org.opends.messages.ConfigMessages.*;
import java.util.Collection;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.messages.Severity;
import org.opends.server.admin.ClassPropertyDefinition;
@@ -66,7 +67,7 @@
  /**
   * The constructor for this class.
   */
  public ErrorLogger()
  private ErrorLogger()
  {
    super((Class) ErrorLogPublisher.class,
        ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS);
@@ -82,41 +83,9 @@
  /** {@inheritDoc} */
  @Override
  protected LoggerStorage<ErrorLogPublisher<ErrorLogPublisherCfg>,
      ErrorLogPublisherCfg> getStorage()
  protected Collection<ErrorLogPublisher<ErrorLogPublisherCfg>> getLogPublishers()
  {
    return loggerStorage;
  }
  /**
   * Add an error log publisher to the error logger.
   *
   * @param publisher The error log publisher to add.
   */
  public synchronized static void addErrorLogPublisher(
      ErrorLogPublisher publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /**
   * Remove an error log publisher from the error logger.
   *
   * @param publisher The error log publisher to remove.
   * @return True if the error log publisher is removed or false otherwise.
   */
  public synchronized static boolean removeErrorLogPublisher(
      ErrorLogPublisher publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /**
   * Removes all existing error log publishers from the logger.
   */
  public synchronized static void removeAllErrorLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
    return loggerStorage.getLogPublishers();
  }
  /**
@@ -188,4 +157,27 @@
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void addLogPublisher(
      ErrorLogPublisher<ErrorLogPublisherCfg> publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized boolean removeLogPublisher(
      ErrorLogPublisher<ErrorLogPublisherCfg> publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void removeAllLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/HTTPAccessLogger.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2013 ForgeRock AS
 *      Copyright 2013-2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -54,7 +54,7 @@
  /**
   * The constructor for this class.
   */
  public HTTPAccessLogger()
  private HTTPAccessLogger()
  {
    super((Class) HTTPAccessLogPublisher.class,
        ERR_CONFIG_LOGGER_INVALID_HTTP_ACCESS_LOGGER_CLASS);
@@ -70,10 +70,9 @@
  /** {@inheritDoc} */
  @Override
  protected LoggerStorage<HTTPAccessLogPublisher<HTTPAccessLogPublisherCfg>,
      HTTPAccessLogPublisherCfg> getStorage()
  protected Collection<HTTPAccessLogPublisher<HTTPAccessLogPublisherCfg>> getLogPublishers()
  {
    return loggerStorage;
    return loggerStorage.getLogPublishers();
  }
  /**
@@ -87,39 +86,6 @@
  }
  /**
   * Add an HTTP access log publisher to the HTTP access logger.
   *
   * @param publisher
   *          The HTTP access log publisher to add.
   */
  public synchronized static void addHTTPAccessLogPublisher(
      HTTPAccessLogPublisher publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /**
   * Remove an HTTP access log publisher from the HTTP access logger.
   *
   * @param publisher
   *          The HTTP access log publisher to remove.
   * @return The publisher that was removed or null if it was not found.
   */
  public synchronized static boolean removeHTTPAccessLogPublisher(
      HTTPAccessLogPublisher<HTTPAccessLogPublisherCfg> publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /**
   * Removes all existing HTTP access log publishers from the logger.
   */
  public synchronized static void removeAllHTTPAccessLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
  }
  /**
   * Returns all the registered HTTP access log publishers.
   *
   * @return a Collection of {@link HTTPAccessLogPublisher} objects
@@ -144,4 +110,27 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void addLogPublisher(
      HTTPAccessLogPublisher<HTTPAccessLogPublisherCfg> publisher)
  {
    loggerStorage.addLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized boolean removeLogPublisher(
      HTTPAccessLogPublisher<HTTPAccessLogPublisherCfg> publisher)
  {
    return loggerStorage.removeLogPublisher(publisher);
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void removeAllLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java
@@ -344,7 +344,7 @@
  private TraceSettings getDefaultSettings(FileBasedDebugLogPublisherCfg config)
  {
    return new TraceSettings(TraceSettings.Level.getLevel(
        true,
        false,
        config.isDefaultDebugExceptionsOnly()),
        config.isDefaultOmitMethodEntryArguments(),
        config.isDefaultOmitMethodReturnValue(),
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -719,14 +719,14 @@
      try
      {
        ErrorLogPublisher<?> errorLogPublisher =
        ErrorLogPublisher errorLogPublisher =
            TextErrorLogPublisher.getToolStartupTextErrorPublisher(
            new TextWriter.STREAM(out));
        DebugLogPublisher<?> debugLogPublisher =
        DebugLogPublisher debugLogPublisher =
            TextDebugLogPublisher.getStartupTextDebugPublisher(
            new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
        DebugLogger.addDebugLogPublisher(debugLogPublisher);
        ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
        DebugLogger.getInstance().addLogPublisher(debugLogPublisher);
      }
      catch(Exception e)
      {
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
@@ -637,14 +637,14 @@
      try
      {
        ErrorLogPublisher<?> errorLogPublisher =
        ErrorLogPublisher errorLogPublisher =
            TextErrorLogPublisher.getToolStartupTextErrorPublisher(
            new TextWriter.STREAM(out));
        DebugLogPublisher<?> debugLogPublisher =
        DebugLogPublisher debugLogPublisher =
            TextDebugLogPublisher.getStartupTextDebugPublisher(
            new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
        DebugLogger.addDebugLogPublisher(debugLogPublisher);
        ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
        DebugLogger.getInstance().addLogPublisher(debugLogPublisher);
      }
      catch(Exception e)
      {
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
@@ -865,10 +865,10 @@
      {
        try
        {
          ErrorLogPublisher<?> errorLogPublisher =
          ErrorLogPublisher errorLogPublisher =
              TextErrorLogPublisher.getToolStartupTextErrorPublisher(
                  new TextWriter.STREAM(out));
          ErrorLogger.addErrorLogPublisher(errorLogPublisher);
          ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
        }
        catch(Exception e)
        {
opendj3-server-dev/src/server/org/opends/server/tools/LDAPConnection.java
@@ -34,6 +34,8 @@
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.ConsoleHandler;
import java.util.logging.Logger;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.controls.AuthorizationIdentityResponseControl;
@@ -41,8 +43,7 @@
import org.opends.server.controls.PasswordPolicyErrorType;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.controls.PasswordPolicyWarningType;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TraceSettings;
import org.opends.server.loggers.JdkLoggingFormater;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp;
import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp;
@@ -183,9 +184,10 @@
    if(connectionOptions.isVerbose())
    {
      ConsoleDebugLogPublisher publisher = new ConsoleDebugLogPublisher(err);
      publisher.addTraceSettings(null, new TraceSettings());
      DebugLogger.addDebugLogPublisher(publisher);
      Logger logger = Logger.getLogger("org.opends");
      ConsoleHandler handler = new ConsoleHandler();
      handler.setFormatter(new JdkLoggingFormater());
      logger.addHandler(handler);
    }
    if(connectionOptions.useStartTLS())
opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
@@ -35,8 +35,7 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.loggers.ErrorLogger.removeErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.protocols.asn1.ASN1Exception;
import static org.opends.server.tools.ToolConstants.*;
@@ -95,7 +94,7 @@
    int retCode = mainTaskInfo(args, System.in, System.out, System.err);
    if (errorLogPublisher != null) {
      removeErrorLogPublisher(errorLogPublisher);
      ErrorLogger.getInstance().removeLogPublisher(errorLogPublisher);
    }
    if (retCode != 0) {
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
@@ -402,14 +402,14 @@
  {
    try
    {
      final ErrorLogPublisher<?> errorLogPublisher =
      final ErrorLogPublisher errorLogPublisher =
          TextErrorLogPublisher
              .getToolStartupTextErrorPublisher(new TextWriter.STREAM(out));
      final DebugLogPublisher<?> debugLogPublisher =
      final DebugLogPublisher debugLogPublisher =
          TextDebugLogPublisher
              .getStartupTextDebugPublisher(new TextWriter.STREAM(out));
      ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      DebugLogger.addDebugLogPublisher(debugLogPublisher);
      ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
      DebugLogger.getInstance().addLogPublisher(debugLogPublisher);
    }
    catch (Exception e)
    {
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
@@ -463,14 +463,14 @@
      try
      {
        ErrorLogPublisher<?> errorLogPublisher =
        ErrorLogPublisher errorLogPublisher =
            TextErrorLogPublisher.getToolStartupTextErrorPublisher(
            new TextWriter.STREAM(out));
        DebugLogPublisher<?> debugLogPublisher =
        DebugLogPublisher debugLogPublisher =
            TextDebugLogPublisher.getStartupTextDebugPublisher(
            new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
        DebugLogger.addDebugLogPublisher(debugLogPublisher);
        ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
        DebugLogger.getInstance().addLogPublisher(debugLogPublisher);
      }
      catch(Exception e)
      {
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
@@ -370,16 +370,16 @@
      try
      {
        ErrorLogPublisher<?> errorLogPublisher =
        ErrorLogPublisher errorLogPublisher =
            TextErrorLogPublisher.getToolStartupTextErrorPublisher(
            new TextWriter.STREAM(out));
        DebugLogPublisher<?> debugLogPublisher =
        DebugLogPublisher debugLogPublisher =
            TextDebugLogPublisher.getStartupTextDebugPublisher(
            new TextWriter.STREAM(out));
        debugLogPublisher.addTraceSettings(null,
            new TraceSettings());
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
        DebugLogger.addDebugLogPublisher(debugLogPublisher);
        ErrorLogger.getInstance().addLogPublisher(errorLogPublisher);
        DebugLogger.getInstance().addLogPublisher(debugLogPublisher);
      }
      catch(Exception e)
      {
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -41,7 +41,11 @@
import org.opends.server.admin.client.ldap.LDAPConnection;
import org.opends.server.admin.client.ldap.LDAPManagementContext;
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.api.AccessLogPublisher;
import org.opends.server.api.Backend;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.HTTPAccessLogPublisher;
import org.opends.server.api.WorkQueue;
import org.opends.server.backends.MemoryBackend;
import org.opends.server.backends.jeb.*;
@@ -463,21 +467,20 @@
      config.setConfigClass(ConfigFileHandler.class);
      config.setConfigFile(new File(testConfigDir, "config.ldif"));
      AccessLogger.addAccessLogPublisher(
          TextAccessLogPublisher.getStartupTextAccessPublisher(
              ACCESS_TEXT_WRITER, false));
      AccessLogger.getInstance().addLogPublisher(
          (AccessLogPublisher) TextAccessLogPublisher
              .getStartupTextAccessPublisher(ACCESS_TEXT_WRITER, false));
      HTTPAccessLogger.addHTTPAccessLogPublisher(TextHTTPAccessLogPublisher
          .getStartupTextHTTPAccessPublisher(HTTP_ACCESS_TEXT_WRITER));
      HTTPAccessLogger.getInstance().addLogPublisher(
          (HTTPAccessLogPublisher) TextHTTPAccessLogPublisher
              .getStartupTextHTTPAccessPublisher(HTTP_ACCESS_TEXT_WRITER));
      // Use more verbose tool logger.
      ErrorLogger.addErrorLogPublisher(
         TextErrorLogPublisher.getToolStartupTextErrorPublisher(
              ERROR_TEXT_WRITER));
      // Enable more verbose error logger.
      ErrorLogger.getInstance().addLogPublisher(
            (ErrorLogPublisher) TextErrorLogPublisher.getToolStartupTextErrorPublisher(ERROR_TEXT_WRITER));
      DebugLogger.addDebugLogPublisher(
         TextDebugLogPublisher.getStartupTextDebugPublisher(
              DEBUG_TEXT_WRITER));
      DebugLogger.getInstance().addLogPublisher(
            (DebugLogPublisher) TextDebugLogPublisher.getStartupTextDebugPublisher(DEBUG_TEXT_WRITER));
      // Writing the buildinfo with the current version.
      final FileWriter buildInfoWriter = new FileWriter (new File(testConfigDir, "buildinfo"));