Search in sources :

Example 21 with LogConfig

use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.

the class FrameworkLoggerTest method testDummyFrameworkLogger.

/**
	 * Other framework loggers did not have the same problem
	 * as the jacorb logger. Thus this test always passed.
	 */
@Test
public void testDummyFrameworkLogger() throws Exception {
    LogConfig logConfig = clientLogManager.getLogConfig();
    final String expectedFrameworkLoggerName = "myFW@" + FrameworkLoggerTest.class.getSimpleName();
    assertThat("Dummy framework logger should NOT be known beforehand.", logConfig.isKnownLogger(expectedFrameworkLoggerName), is(false));
    assertThat("Framework logger configuration should be DEBUG, as controlled by ACS_LOG_STDOUT.", AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(expectedFrameworkLoggerName).getMinLogLevelLocal()), equalTo(AcsLogLevelDefinition.DEBUG));
    // Check if the framework logger is configured in line with the above logConfig results
    AcsLogger myFWLogger = ClientLogManager.getAcsLogManager().getLoggerForCorba("myFW", true);
    myFWLogger.finer("A framework test log, should be shown.");
    assertThat(myFWLogger.isLoggable(AcsLogLevel.TRACE), is(false));
    assertThat(myFWLogger.isLoggable(AcsLogLevel.DELOUSE), is(true));
}
Also used : LogConfig(alma.acs.logging.config.LogConfig) AcsLogger(alma.acs.logging.AcsLogger) Test(org.junit.Test)

Example 22 with LogConfig

use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.

the class FrameworkLoggerTest method testJacorbLogger.

@Test
public void testJacorbLogger() throws Exception {
    LogConfig logConfig = clientLogManager.getLogConfig();
    final String expectedJacorbLoggerName = "jacorb@" + FrameworkLoggerTest.class.getSimpleName();
    assertThat("jacorb logger should be known already from base class corba calls.", logConfig.isKnownLogger(expectedJacorbLoggerName), is(true));
    // JacORB config file "orb.properties" currently contains "jacorb.log.default.verbosity=2" (mapped to INFO), 
    // but it is not visible as a system property and thus cannot be verified here.
    // This test must be started with "-Djacorb.log.default.verbosity=3" (DEBUG) so that we can assert
    // the right jacorb log level.
    assertThat("Expected system property jacorb.log.default.verbosity=3 set. Check the test start script!", System.getProperty("jacorb.log.default.verbosity"), equalTo("3"));
    assertThat("Stdout log level must be DEBUG or lower, to not override the jacorb log level.", logConfig.getDefaultMinLogLevelLocal(), lessThanOrEqualTo(AcsLogLevelDefinition.DEBUG));
    assertThat("jacorb logger configuration should be DEBUG for local logging.", AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(expectedJacorbLoggerName).getMinLogLevelLocal()), equalTo(AcsLogLevelDefinition.DEBUG));
    // Check if the jacorb logger itself is configured according to the above logConfig results
    AcsLogger jacorbLogger = ClientLogManager.getAcsLogManager().getLoggerForCorba("jacorb", true);
    jacorbLogger.fine("A jacorb test log, should be shown.");
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.TRACE), is(false));
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.DELOUSE), is(false));
    assertThat(jacorbLogger.isLoggable(AcsLogLevel.DEBUG), is(true));
    // This setMinLogLevelLocal effects a call to LogConfig#notifySubscribers(), 
    // which in the past brought out the jacorb logs even when the above "A jacorb test log, should be shown." 
    // was not logged due a bug.
    logConfig.setMinLogLevelLocal(AcsLogLevelDefinition.DELOUSE, "SomeOtherFramework");
    jacorbLogger.finer("jacorb test log #2, shown.");
}
Also used : LogConfig(alma.acs.logging.config.LogConfig) AcsLogger(alma.acs.logging.AcsLogger) Test(org.junit.Test)

Example 23 with LogConfig

use of alma.acs.logging.config.LogConfig in project ACS by ACS-Community.

the class ManagerProxyImpl method get_logger_names.

/**
	 * Gets the names of all loggers, to allow configuring their levels
	 * individually. The names are those that appear in the log records in the
	 * field "SourceObject". This includes the container logger, ORB logger,
	 * component loggers, and (only C++) GlobalLogger.
	 */
public String[] get_logger_names() {
    pendingRequests.incrementAndGet();
    try {
        LogConfig logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
        Set<String> loggerNames = logConfig.getLoggerNames();
        return loggerNames.toArray(new String[loggerNames.size()]);
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : LogConfig(alma.acs.logging.config.LogConfig)

Aggregations

LogConfig (alma.acs.logging.config.LogConfig)23 AcsLogger (alma.acs.logging.AcsLogger)3 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)3 Test (org.junit.Test)3 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)2 IllegalLogLevelsEx (alma.Logging.IllegalLogLevelsEx)2 LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)2 UnnamedLogger (alma.maci.loggingconfig.UnnamedLogger)2 Level (java.util.logging.Level)2 LogRecord (java.util.logging.LogRecord)2 Logger (java.util.logging.Logger)2 DaemonThreadFactory (alma.acs.concurrent.DaemonThreadFactory)1 AcsLogLevel (alma.acs.logging.AcsLogLevel)1 LogConfigException (alma.acs.logging.config.LogConfigException)1 LogReceiver (alma.acs.logging.engine.LogReceiver)1 DelayedLogEntry (alma.acs.logging.engine.LogReceiver.DelayedLogEntry)1 AcsXMLLogFormatter (alma.acs.logging.formatters.AcsXMLLogFormatter)1 CoreException (com.cosylab.acs.maci.CoreException)1 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)1 CORBATransport (com.cosylab.acs.maci.plug.CORBATransport)1