opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -69,9 +69,6 @@ import org.opends.server.api.SynchronizationProvider; import org.opends.server.api.TrustManagerProvider; import org.opends.server.api.WorkQueue; import org.opends.server.api.AccessLogPublisher; import org.opends.server.api.ErrorLogPublisher; import org.opends.server.api.DebugLogPublisher; import org.opends.server.api.AccessControlHandler; import org.opends.server.api.plugin.PluginType; import org.opends.server.api.plugin.StartupPluginResult; @@ -87,13 +84,10 @@ import org.opends.server.extensions.JMXAlertHandler; import static org.opends.server.loggers.AccessLogger.*; import static org.opends.server.loggers.ErrorLogger.*; import org.opends.server.loggers.RetentionPolicy; import org.opends.server.loggers.RotationPolicy; import org.opends.server.loggers.TextErrorLogPublisher; import org.opends.server.loggers.TextWriter; import org.opends.server.loggers.*; import static org.opends.server.loggers.debug.DebugLogger.*; import org.opends.server.loggers.debug.DebugTracer; import org.opends.server.loggers.debug.TextDebugLogPublisher; import org.opends.server.loggers.debug.DebugLogger; import org.opends.messages.MessageDescriptor; import org.opends.messages.Message; @@ -1001,27 +995,6 @@ Thread.setDefaultUncaughtExceptionHandler(this); // Install default debug and error loggers for use until enough of the // configuration has been read to allow the real loggers to be installed. removeAllAccessLogPublishers(); for (AccessLogPublisher p : environmentConfig.getAccessLoggers()) { addAccessLogPublisher(p); } removeAllErrorLogPublishers(); for (ErrorLogPublisher p : environmentConfig.getErrorLoggers()) { addErrorLogPublisher(p); } removeAllDebugLogPublishers(); for (DebugLogPublisher p : environmentConfig.getDebugLoggers()) { addDebugLogPublisher(p); } // Create the MBean server that we will use for JMX interaction. initializeJMX(); @@ -1322,12 +1295,12 @@ retentionPolicyConfigManager = new LogRetentionPolicyConfigManager(); retentionPolicyConfigManager.initializeLogRetentionPolicyConfig(); // Initialize the server loggers. loggerConfigManager = new LoggerConfigManager(); loggerConfigManager.initializeLoggerConfig(); // Initialize the server alert handlers. initializeAlertHandlers(); @@ -1481,17 +1454,9 @@ sendAlertNotification(this, ALERT_TYPE_SERVER_STARTED, message); for(DebugLogPublisher startupDebugLogPublisher : environmentConfig.getDebugLoggers()) { removeDebugLogPublisher(startupDebugLogPublisher); } for(ErrorLogPublisher startupErrorLogPublisher : environmentConfig.getErrorLoggers()) { removeErrorLogPublisher(startupErrorLogPublisher); } // Remove default loggers ErrorLogger.removeFirstErrorLogPublisher(); DebugLogger.removeFirstDebugLogPublisher(); // Force the root connection to be initialized. InternalClientConnection.getRootConnection(); @@ -9525,8 +9490,6 @@ // Create an environment configuration for the server and populate a number // of appropriate properties. TextErrorLogPublisher startupErrorLogPublisher = null; TextDebugLogPublisher startupDebugLogPublisher = null; DirectoryEnvironmentConfig environmentConfig = new DirectoryEnvironmentConfig(); try @@ -9537,17 +9500,6 @@ configFile.getValue()); environmentConfig.setProperty(PROPERTY_USE_LAST_KNOWN_GOOD_CONFIG, String.valueOf(useLastKnownGoodConfig.isPresent())); startupErrorLogPublisher = TextErrorLogPublisher.getStartupTextErrorPublisher( new TextWriter.STDOUT()); environmentConfig.addErrorLogger(startupErrorLogPublisher); startupDebugLogPublisher = TextDebugLogPublisher.getStartupTextDebugPublisher( new TextWriter.STDOUT()); environmentConfig.addDebugLogger(startupDebugLogPublisher); } catch (Exception e) { opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java
@@ -76,6 +76,14 @@ // The singleton instance of this class for configuration purposes. private static final ErrorLogger instance = new ErrorLogger(); static { // Add the default publisher to stdout. addErrorLogPublisher( TextErrorLogPublisher.getStartupTextErrorPublisher( new TextWriter.STDOUT())); } /** * Retrieve the singleton instance of this class. * @@ -130,6 +138,19 @@ } /** * Removes first error log publisher from the logger. */ public synchronized static void removeFirstErrorLogPublisher() { if(!errorPublishers.isEmpty()) { ErrorLogPublisher publisher = errorPublishers.remove(0); publisher.close(); } } /** * Initializes all the error log publishers. * * @param configs The error log publisher configurations. opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
@@ -93,6 +93,14 @@ // The singleton instance of this class for configuration purposes. static final DebugLogger instance = new DebugLogger(); static { // Add the default publisher to stdout. addDebugLogPublisher( TextDebugLogPublisher.getStartupTextDebugPublisher( new TextWriter.STDOUT())); } /** * Add an debug log publisher to the debug logger. * @@ -152,6 +160,26 @@ } /** * Removes first debug log publisher from the logger. */ public synchronized static void removeFirstDebugLogPublisher() { if(!debugPublishers.isEmpty()) { DebugLogPublisher publisher = debugPublishers.remove(0); publisher.close(); } updateTracerSettings(); if(debugPublishers.isEmpty()) { enabled = false; } } /** * Initializes all the debug log publishers. * * @param configs The debug log publisher configurations. opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java
@@ -29,17 +29,12 @@ import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.opends.server.api.AccessLogPublisher; import org.opends.server.api.ConfigHandler; import org.opends.server.api.DebugLogPublisher; import org.opends.server.api.ErrorLogPublisher; import org.opends.server.core.DirectoryServer; import org.opends.server.extensions.ConfigFileHandler; @@ -63,18 +58,6 @@ mayInvoke=true) public final class DirectoryEnvironmentConfig { // The set of access loggers that should be put in place before the // server is started. private final ArrayList<AccessLogPublisher> accessLoggers; // The set of debug loggers that should be put in place before the // server is started. private final ArrayList<DebugLogPublisher> debugLoggers; // The set of error loggers that should be put in place before the // server is started. private final ArrayList<ErrorLogPublisher> errorLoggers; // The set of properties for the environment config. private final HashMap<String,String> configProperties; @@ -112,10 +95,6 @@ String.valueOf(properties.get(o))); } } accessLoggers = new ArrayList<AccessLogPublisher>(); debugLoggers = new ArrayList<DebugLogPublisher>(); errorLoggers = new ArrayList<ErrorLogPublisher>(); } @@ -138,10 +117,6 @@ { configProperties = new HashMap<String,String>(properties); } accessLoggers = new ArrayList<AccessLogPublisher>(); debugLoggers = new ArrayList<DebugLogPublisher>(); errorLoggers = new ArrayList<ErrorLogPublisher>(); } @@ -1329,134 +1304,5 @@ } } } /** * Retrieves the list of access loggers that should be enabled in * the server during the startup process. Note that these loggers * will not be automatically disabled when startup is complete, so * if they are no longer needed then they should be manually removed * from the server using the * {@code AccessLogger.removeAccessLogPublisher} method. * * @return The list of access loggers that should be enabled in the * server during the startup process. */ public List<AccessLogPublisher> getAccessLoggers() { return accessLoggers; } /** * Adds the provided access logger to the set of loggers that should * be enabled in the server during the startup process. * * @param accessLogger The access logger that should be added to * the set of loggers enabled in the server * during the startup process. * * @throws InitializationException If the Directory Server is * already running. */ public void addAccessLogger(AccessLogPublisher accessLogger) throws InitializationException { if (DirectoryServer.isRunning()) { throw new InitializationException( ERR_DIRCFG_SERVER_ALREADY_RUNNING.get()); } accessLoggers.add(accessLogger); } /** * Retrieves the list of error loggers that should be enabled in * the server during the startup process. Note that these loggers * will not be automatically disabled when startup is complete, so * if they are no longer needed then they should be manually removed * from the server using the * {@code ErrorLogger.removeErrorLogPublisher} method. * * @return The list of error loggers that should be enabled in the * server during the startup process. */ public List<ErrorLogPublisher> getErrorLoggers() { return errorLoggers; } /** * Adds the provided error logger to the set of loggers that should * be enabled in the server during the startup process. * * @param errorLogger The error logger that should be added to the * set of loggers enabled in the server during * the startup process. * * @throws InitializationException If the Directory Server is * already running. */ public void addErrorLogger(ErrorLogPublisher errorLogger) throws InitializationException { if (DirectoryServer.isRunning()) { throw new InitializationException( ERR_DIRCFG_SERVER_ALREADY_RUNNING.get()); } errorLoggers.add(errorLogger); } /** * Retrieves the list of debug loggers that should be enabled in * the server during the startup process. Note that these loggers * will not be automatically disabled when startup is complete, so * if they are no longer needed then they should be manually removed * from the server using the * {@code DebugLogger.removeDebugLogPublisher} method. * * @return The list of debug loggers that should be enabled in the * server during the startup process. */ public List<DebugLogPublisher> getDebugLoggers() { return debugLoggers; } /** * Adds the provided debug logger to the set of loggers that should * be enabled in the server during the startup process. * * @param debugLogger The debug logger that should be added to * the set of loggers enabled in the server * during the startup process. * * @throws InitializationException If the Directory Server is * already running. */ public void addDebugLogger(DebugLogPublisher debugLogger) throws InitializationException { if (DirectoryServer.isRunning()) { throw new InitializationException( ERR_DIRCFG_SERVER_ALREADY_RUNNING.get()); } debugLoggers.add(debugLogger); } } opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -81,7 +81,10 @@ import org.opends.server.extensions.ConfigFileHandler; import org.opends.server.loggers.TextAccessLogPublisher; import org.opends.server.loggers.TextErrorLogPublisher; import org.opends.server.loggers.AccessLogger; import org.opends.server.loggers.ErrorLogger; import org.opends.server.loggers.debug.TextDebugLogPublisher; import org.opends.server.loggers.debug.DebugLogger; import org.opends.server.plugins.InvocationCounterPlugin; import org.opends.server.protocols.asn1.ASN1OctetString; import org.opends.server.protocols.asn1.ASN1Reader; @@ -366,15 +369,18 @@ config.setConfigClass(ConfigFileHandler.class); config.setConfigFile(new File(testConfigDir, "config.ldif")); config.addAccessLogger( AccessLogger.removeAllAccessLogPublishers(); AccessLogger.addAccessLogPublisher( TextAccessLogPublisher.getStartupTextAccessPublisher( ACCESS_TEXT_WRITER, false)); config.addErrorLogger( ErrorLogger.removeAllErrorLogPublishers(); ErrorLogger.addErrorLogPublisher( TextErrorLogPublisher.getStartupTextErrorPublisher( ERROR_TEXT_WRITER)); config.addDebugLogger( DebugLogger.removeAllDebugLogPublishers(); DebugLogger.addDebugLogPublisher( TextDebugLogPublisher.getStartupTextDebugPublisher( DEBUG_TEXT_WRITER)); @@ -1624,4 +1630,3 @@ return buffer.toString(); } }