Search in sources :

Example 1 with LoggingConfig

use of alma.maci.loggingconfig.LoggingConfig in project ACS by ACS-Community.

the class LogConfigTest method testGetLogConfigXml.

/**
	 * Test for the XPath based {@link LogConfig#getLogConfigXml(String, String)} which extracts log info from the XML 
	 * that we get from the CDB.
	 */
public void testGetLogConfigXml() throws Exception {
    logger.info("============ Running testGetLogConfigXml ============");
    File containerConfigFile = new File("frodoContainer.xml");
    assertTrue("Cannot find file frodoContainer.xml. Check that file exists and test is run with working dir acsjlog/test.", containerConfigFile.exists());
    String containerConfigXml = (new ReaderExtractor((new FileReader(containerConfigFile)))).extract();
    logger.info("containerConfigXml = " + containerConfigXml);
    assertNotNull(containerConfigXml);
    assertFalse(containerConfigXml.isEmpty());
    TestCDB testCDB = new TestCDB();
    logConfig.setCDB(testCDB);
    String cdbContainerConfigPath = "frodoContainer";
    testCDB.addCurlToXmlMapping(cdbContainerConfigPath, containerConfigXml);
    logConfig.setCDBLoggingConfigPath(cdbContainerConfigPath);
    String xml = logConfig.getLogConfigXml(cdbContainerConfigPath, "//" + LogConfig.CDBNAME_LoggingConfig);
    assertNotNull(xml);
    logger.info("Got container logging config xml: " + xml);
    LoggingConfig loggingConfig = LoggingConfig.unmarshalLoggingConfig(new StringReader(xml));
    assertNotNull(loggingConfig);
    String separateConfigComponent1 = "testComp1";
    String separateConfigComponent2 = "testComp2";
    String componentsXml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> " + "<Components xmlns=\"urn:schemas-cosylab-com:Components:1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> " + createComponentsCdbXml(separateConfigComponent1, "IDL_TYPE_1", "some.class1", "zampaione", true, 2, 8) + createComponentsCdbXml(separateConfigComponent2, "IDL_TYPE_2", "some.class2", "zampaione", true, 5, 6) + "</Components>";
    logger.info("componentsXml = " + componentsXml);
    String cdbComponentsPath = "MACI/Components";
    logConfig.setCDB(testCDB);
    testCDB.addCurlToXmlMapping(cdbComponentsPath, componentsXml);
    logConfig.setCDBComponentPath(separateConfigComponent1, cdbComponentsPath);
    logConfig.setCDBComponentPath(separateConfigComponent2, cdbComponentsPath);
    String expr = "//_[@Name='" + separateConfigComponent2 + "']/ComponentLogger";
    xml = logConfig.getLogConfigXml("MACI/Components", expr);
    assertNotNull(xml);
    logger.info("Got component config xml: " + xml);
    UnnamedLogger compLoggerConfig = UnnamedLogger.unmarshalUnnamedLogger(new StringReader(xml));
    assertNotNull(compLoggerConfig);
}
Also used : ReaderExtractor(alma.acs.util.ReaderExtractor) UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) LoggingConfig(alma.maci.loggingconfig.LoggingConfig) StringReader(java.io.StringReader) FileReader(java.io.FileReader) File(java.io.File)

Example 2 with LoggingConfig

use of alma.maci.loggingconfig.LoggingConfig in project ACS by ACS-Community.

the class LogConfig method initialize.

/**
	 * Initializes the values based on CDB settings, logging properties, etc. All subscribing classes are notified of
	 * the new configuration, see {@link LogConfigSubscriber#configureLogging(LogConfig)}.
	 * <p>
	 * This method can be called more than once: if some settings have changed, should be read in, and the logging
	 * classes should be notified of these changes. For example, the container could call this method when it gets
	 * notified that the logging configuration in the CDB has been changed at runtime.
	 * 
	 * @param cdbBeatsProperties
	 *            if true then the default logger level values from the CDB override the properties (env vars).
	 *            <code>True</code> is foreseen for dynamic updates from the CDB, whereas for the initial
	 *            configuration it should be a <code>false</code>.
	 * 
	 * @throws LogConfigException
	 *            if reading the configuration data failed and thus default values were used, or if there were problems
	 *            during configuration even though some of the configuring went ok (best-effort approach).
	 */
public void initialize(boolean cdbBeatsProperties) throws LogConfigException {
    StringBuffer errMsg = new StringBuffer();
    // schema binding class generated from LogggingConfig.xsd
    LoggingConfig newLoggingConfig = null;
    if (cdb != null) {
        try {
            if (cdbLoggingConfigPath != null) {
                String loggingConfigXml = getLogConfigXml(cdbLoggingConfigPath, "//" + CDBNAME_LoggingConfig);
                if (loggingConfigXml == null || loggingConfigXml.trim().isEmpty()) {
                    // the LoggingConfig child is mandatory for containers and manager
                    throw new LogConfigException("Node " + cdbLoggingConfigPath + " does not contain one LoggingConfig element.");
                }
                try {
                    newLoggingConfig = LoggingConfig.unmarshalLoggingConfig(new StringReader(loggingConfigXml));
                } catch (Throwable thr) {
                    log(Level.FINE, "Failed to unmarshal logging config xml '" + loggingConfigXml + "'.", thr);
                    throw thr;
                }
            } else {
                errMsg.append("CDB reference was set, but not the path to the logging configuration. ");
            }
            if (newLoggingConfig != null) {
                loggingConfig = newLoggingConfig;
                synchronized (namedLoggerConfigs) {
                    // but only null their configurations.
                    for (String loggerName : namedLoggerConfigs.keySet()) {
                        storeNamedLoggerConfig(loggerName, null);
                    }
                    // named logger levels from children of the <LoggingConfig/> 
                    NamedLogger[] namedLoggers = loggingConfig.get();
                    for (int i = 0; i < namedLoggers.length; i++) {
                        storeNamedLoggerConfig(namedLoggers[i].getName(), new LockableUnnamedLogger(namedLoggers[i]));
                    }
                    // check CDB config for all component loggers who got a CDB path configured
                    for (String loggerName : cdbComponentPaths.keySet()) {
                        // skip named logger if it's been already configured from the main XML, since those values have precedence
                        if (!namedLoggerConfigs.containsKey(loggerName)) {
                            String cdbPath = cdbComponentPaths.get(loggerName);
                            String xpath = "//_[@Name='" + loggerName + "']/" + CDBNAME_ComponentLogger;
                            String componentConfigXML = getLogConfigXml(cdbPath, xpath);
                            // the ComponentLogger xml child element is optional, we get a null if it's missing.
                            if (componentConfigXML != null) {
                                UnnamedLogger compLoggerConfig;
                                try {
                                    compLoggerConfig = UnnamedLogger.unmarshalUnnamedLogger(new StringReader(componentConfigXML));
                                } catch (Throwable thr) {
                                    log(Level.FINE, "Failed to unmarshal component config xml '" + componentConfigXML + "'.", thr);
                                    throw thr;
                                }
                                storeNamedLoggerConfig(loggerName, new LockableUnnamedLogger(compLoggerConfig));
                            }
                        }
                    }
                }
            } else {
                throw new LogConfigException("LoggingConfig binding class obtained from CDB node '" + cdbLoggingConfigPath + "' was null.");
            }
        } catch (CDBXMLErrorEx ex) {
            errMsg.append("Failed to read node " + cdbLoggingConfigPath + " from the CDB (msg='" + ex.errorTrace.shortDescription + "'). ");
        } catch (CDBRecordDoesNotExistEx ex) {
            errMsg.append("Node " + cdbLoggingConfigPath + " does not exist in the CDB (msg='" + ex.errorTrace.shortDescription + "'). ");
        } catch (CastorException ex) {
            errMsg.append("Failed to parse XML for CDB node " + cdbLoggingConfigPath + " into binding classes (ex=" + ex.getClass().getName() + ", msg='" + ex.getMessage() + "'). ");
        } catch (Throwable thr) {
            errMsg.append("Failed to read node " + cdbLoggingConfigPath + " from the CDB (ex=" + thr.getClass().getName() + ", msg='" + thr.getMessage() + "'). ");
        }
    }
    // consider the env var based properties only if the CDB was not considered or if the CDB settings should not override the env vars 
    if (cdb == null || !cdbBeatsProperties) {
        configureDefaultLevelsFromProperties();
        configureNamedLoggerLevelsFromProperties();
    }
    notifySubscribers();
    // present), we can publish a trace log
    if (newLoggingConfig != null) {
        StringWriter writer = new StringWriter();
        String newXML = null;
        try {
            newLoggingConfig.marshal(writer);
            newXML = writer.toString().trim();
        } catch (Throwable thr) {
            // nothing
            ;
        }
        String msg = "Updated logging configuration based on CDB entry " + newXML;
        msg += " with " + (cdbBeatsProperties ? "CDB" : "env vars") + " having precedence over " + (cdbBeatsProperties ? "env vars" : "CDB");
        log(Level.FINER, msg, null);
    // @TODO: also log something for named component loggers if any were considered 
    } else {
        log(Level.FINER, "Logging configuration has been initialized, but not from CDB settings.", null);
    }
    if (errMsg.length() > 0) {
        throw new LogConfigException("Log config initialization at least partially failed. " + errMsg.toString());
    }
}
Also used : NamedLogger(alma.maci.loggingconfig.NamedLogger) UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) CDBXMLErrorEx(alma.cdbErrType.CDBXMLErrorEx) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx) StringWriter(java.io.StringWriter) LoggingConfig(alma.maci.loggingconfig.LoggingConfig) StringReader(java.io.StringReader) CastorException(org.exolab.castor.core.exceptions.CastorException)

Example 3 with LoggingConfig

use of alma.maci.loggingconfig.LoggingConfig in project ACS by ACS-Community.

the class LogConfigTest method testDefaultValues.

/**
	 * Tests the config values returned from {@link LogConfig} 
	 * with at most env vars for default levels being set (can be enforced by TAT!),
	 * but without CDB or other information being considered.
	 * <p>
	 * Also asserts that none of these calls return the original object, 
	 * but instead a copy of it. This indirectly exercises the equals method.
	 */
public void testDefaultValues() throws Exception {
    logger.info("============ Running testDefaultValues ============");
    assertEquals("Log", logConfig.getCentralizedLogger());
    assertEquals(100, logConfig.getDispatchPacketSize());
    LoggingConfig schemaDefaults = new LoggingConfig();
    // We verify that the castor-generated class actually has the current schema defaults.
    // These values must be adjusted when the schema is changed.
    // In that case also the values in the simulated CDB's xml might have to be changed
    // in order to still be different from the default values.
    // 0 named loggers
    assertEquals(0, schemaDefaults.getCount());
    assertEquals(100, schemaDefaults.getDispatchPacketSize());
    assertEquals(10, schemaDefaults.getFlushPeriodSeconds());
    assertEquals(LogLevel.VALUE_10, schemaDefaults.getImmediateDispatchLevel());
    assertEquals(1000, schemaDefaults.getMaxLogQueueSize());
    assertEquals(LogLevel.VALUE_2, schemaDefaults.getMinLogLevelLocal());
    assertEquals(LogLevel.VALUE_2, schemaDefaults.getMinLogLevel());
    assertEquals("Log", schemaDefaults.getCentralizedLogger());
    AcsLogLevelDefinition defaultMinLogLevelLocal = AcsLogLevelDefinition.fromXsdLogLevel(schemaDefaults.getMinLogLevelLocal());
    // but if env vars are set, we may have different default levels
    Integer PROP_ACS_LOG_STDOUT = Integer.getInteger(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL_LOCAL);
    if (PROP_ACS_LOG_STDOUT != null) {
        defaultMinLogLevelLocal = AcsLogLevelDefinition.fromInteger(PROP_ACS_LOG_STDOUT.intValue());
        logger.info("Using default stdout level from env var: " + defaultMinLogLevelLocal);
    } else {
        logger.info("No env var setting found for " + LogConfig.PROPERTYNAME_MIN_LOG_LEVEL_LOCAL);
    }
    AcsLogLevelDefinition defaultMinLogLevel = AcsLogLevelDefinition.fromXsdLogLevel(schemaDefaults.getMinLogLevel());
    Integer PROP_ACS_LOG_REMOTE = Integer.getInteger(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL);
    if (PROP_ACS_LOG_REMOTE != null) {
        defaultMinLogLevel = AcsLogLevelDefinition.fromInteger(PROP_ACS_LOG_REMOTE.intValue());
        logger.info("Using default remote level from env var: " + defaultMinLogLevelLocal);
    } else {
        logger.info("No env var setting found for " + LogConfig.PROPERTYNAME_MIN_LOG_LEVEL);
    }
    // our logConfig should give the correct default values, coming from schema or env var
    assertEquals(defaultMinLogLevelLocal, logConfig.getDefaultMinLogLevelLocal());
    assertEquals(defaultMinLogLevel, logConfig.getDefaultMinLogLevel());
    // Check default data other than log levels
    assertEquals(schemaDefaults.getCentralizedLogger(), logConfig.getCentralizedLogger());
    assertEquals(schemaDefaults.getImmediateDispatchLevel(), logConfig.getImmediateDispatchLevel().toXsdLevel());
    assertEquals(schemaDefaults.getDispatchPacketSize(), logConfig.getDispatchPacketSize());
    assertEquals(schemaDefaults.getFlushPeriodSeconds(), logConfig.getFlushPeriodSeconds());
    // Get log levels for not existing named loggers, which should result in the default log levels being used
    UnnamedLogger namedLogConfig1 = logConfig.getNamedLoggerConfig(null);
    assertEquals(defaultMinLogLevel, AcsLogLevelDefinition.fromXsdLogLevel(namedLogConfig1.getMinLogLevel()));
    assertEquals(defaultMinLogLevelLocal, AcsLogLevelDefinition.fromXsdLogLevel(namedLogConfig1.getMinLogLevelLocal()));
    UnnamedLogger namedLogConfig2 = logConfig.getNamedLoggerConfig("nonExistingLogger");
    assertNotSame(namedLogConfig1, namedLogConfig2);
    assertEquals(defaultMinLogLevel, AcsLogLevelDefinition.fromXsdLogLevel(namedLogConfig2.getMinLogLevel()));
    assertEquals(defaultMinLogLevelLocal, AcsLogLevelDefinition.fromXsdLogLevel(namedLogConfig2.getMinLogLevelLocal()));
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) AcsLogLevelDefinition(alma.acs.logging.level.AcsLogLevelDefinition) LoggingConfig(alma.maci.loggingconfig.LoggingConfig)

Example 4 with LoggingConfig

use of alma.maci.loggingconfig.LoggingConfig in project ACS by ACS-Community.

the class LogConfigTest method testCDBValues.

/**
	 * Tests logging config from the CDB, for both cases
	 * (a) that env vars beat CDB settings e.g. for normal CDB reading,
	 * (b) that CDB beats env vars e.g. during a refresh from CDB triggered via LoggingConfigurable API. 
	 */
public void testCDBValues() throws Exception {
    logger.info("============ Running testCDBValues ============");
    // we simulate an ACS_LOG_STDOUT env var setting
    String ACS_LOG_STDOUT_ORIGINAL = System.getProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL_LOCAL);
    String ACS_LOG_REMOTE_ORIGINAL = System.getProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL);
    String ACS_LOG_STDOUT = "" + AcsLogLevelDefinition.EMERGENCY.value;
    assertFalse("Fix this test to chose a different env var than the default", ACS_LOG_STDOUT.equals(ACS_LOG_STDOUT_ORIGINAL));
    System.setProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL_LOCAL, ACS_LOG_STDOUT);
    logger.info("Set property (env var) for local default level to " + ACS_LOG_STDOUT);
    // and remove any possibly present property from env var ACS_LOG_CENTRAL
    System.clearProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL);
    logger.info("Removed property (env var) for remote default level");
    // the schema defaults as reference
    LoggingConfig schemaDefaults = new LoggingConfig();
    AcsLogLevelDefinition defaultMinLogLevel = AcsLogLevelDefinition.fromXsdLogLevel(schemaDefaults.getMinLogLevel());
    AcsLogLevelDefinition defaultMinLogLevelLocal = AcsLogLevelDefinition.fromXsdLogLevel(schemaDefaults.getMinLogLevelLocal());
    // before we read the CDB, let's verify that the env var and default log levels are correct
    logConfig.initialize(false);
    assertEquals(defaultMinLogLevel, logConfig.getDefaultMinLogLevel());
    assertEquals(AcsLogLevelDefinition.EMERGENCY, logConfig.getDefaultMinLogLevelLocal());
    // the simulated test CDB to configure our loggers from
    String cdbContainerPath = "MACI/Containers/frodoContainer";
    String frodoContainerXml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> " + "<Container xmlns=\"urn:schemas-cosylab-com:Container:1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:log=\"urn:schemas-cosylab-com:LoggingConfig:1.0\">" + "<LoggingConfig " + " minLogLevel=\"4\" " + " minLogLevelLocal=\"3\" " + " centralizedLogger=\"LogForFrodo\" " + " maxLogQueueSize=\"200\" " + " immediateDispatchLevel=\"8\" " + " dispatchPacketSize=\"33\" " + " >" + "<log:_ Name=\"MyMuteComponent\" minLogLevel=\"5\" minLogLevelLocal=\"6\" />" + "</LoggingConfig>" + "</Container>";
    TestCDB testCDB = new TestCDB();
    testCDB.addCurlToXmlMapping(cdbContainerPath, frodoContainerXml);
    logConfig.setCDBLoggingConfigPath(cdbContainerPath);
    logConfig.setCDB(testCDB);
    // first the normal case where the env var default level beats the CDB default level
    logConfig.initialize(false);
    assertEquals("CDB must beat schema default", AcsLogLevelDefinition.INFO, logConfig.getDefaultMinLogLevel());
    assertEquals("Env var must beat CDB", AcsLogLevelDefinition.EMERGENCY, logConfig.getDefaultMinLogLevelLocal());
    assertEquals("LogForFrodo", logConfig.getCentralizedLogger());
    assertSame(AcsLogLevelDefinition.ERROR, logConfig.getImmediateDispatchLevel());
    assertEquals(33, logConfig.getDispatchPacketSize());
    assertEquals(200, logConfig.getMaxLogQueueSize());
    Set<String> loggerNames = logConfig.getLoggerNames();
    assertEquals(1, loggerNames.size());
    assertTrue(loggerNames.contains("MyMuteComponent"));
    // was not in CDB, thus default should be used
    assertEquals(schemaDefaults.getFlushPeriodSeconds(), logConfig.getFlushPeriodSeconds());
    // next the special case of CDB refresh via dynamic API, where the CDB beats the env var default levels
    logConfig.initialize(true);
    assertSame("CDB must beat schema default", AcsLogLevelDefinition.INFO, logConfig.getDefaultMinLogLevel());
    assertSame("CDB must beat env var", AcsLogLevelDefinition.DEBUG, logConfig.getDefaultMinLogLevelLocal());
    assertEquals("LogForFrodo", logConfig.getCentralizedLogger());
    assertSame(AcsLogLevelDefinition.ERROR, logConfig.getImmediateDispatchLevel());
    assertEquals(33, logConfig.getDispatchPacketSize());
    assertEquals(200, logConfig.getMaxLogQueueSize());
    loggerNames = logConfig.getLoggerNames();
    assertEquals(1, loggerNames.size());
    assertTrue(loggerNames.contains("MyMuteComponent"));
    // was not in CDB, thus default should be used
    assertEquals(schemaDefaults.getFlushPeriodSeconds(), logConfig.getFlushPeriodSeconds());
    UnnamedLogger myMuteloggerConfig = logConfig.getNamedLoggerConfig("MyMuteComponent");
    assertEquals(LogLevel.VALUE_5, myMuteloggerConfig.getMinLogLevel());
    assertEquals(LogLevel.VALUE_6, myMuteloggerConfig.getMinLogLevelLocal());
    // Test logger configuration given in the CDB separately for a component in the Components.xml file, not with the rest of LoggingConfig in the Container xml.
    String separateConfigComponent1 = "testComp1";
    String separateConfigComponent2 = "testComp2";
    String componentsXml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> " + "<Components xmlns=\"urn:schemas-cosylab-com:Components:1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> " + createComponentsCdbXml(separateConfigComponent1, "IDL_TYPE_1", "some.class1", "zampaione", true, 2, 8) + createComponentsCdbXml(separateConfigComponent2, "IDL_TYPE_2", "some.class2", "zampaione", true, 5, 6) + "</Components>";
    logger.info("componentsXml = " + componentsXml);
    String cdbComponentsPath = "MACI/Components";
    testCDB.addCurlToXmlMapping(cdbComponentsPath, componentsXml);
    logConfig.setCDBComponentPath(separateConfigComponent1, cdbComponentsPath);
    logConfig.setCDBComponentPath(separateConfigComponent2, cdbComponentsPath);
    logConfig.initialize(false);
    loggerNames = logConfig.getLoggerNames();
    //		assertEquals(2, loggerNames.size());
    assertTrue(loggerNames.contains("MyMuteComponent"));
    //		assertTrue(loggerNames.contains(separateConfigComponent1));
    //		assertTrue(loggerNames.contains(separateConfigComponent2));
    UnnamedLogger separateConfig1 = logConfig.getNamedLoggerConfig(separateConfigComponent1);
    assertEquals(LogLevel.VALUE_2, separateConfig1.getMinLogLevel());
    assertEquals(LogLevel.VALUE_8, separateConfig1.getMinLogLevelLocal());
    UnnamedLogger separateConfig2 = logConfig.getNamedLoggerConfig(separateConfigComponent2);
    assertEquals(LogLevel.VALUE_5, separateConfig2.getMinLogLevel());
    assertEquals(LogLevel.VALUE_6, separateConfig2.getMinLogLevelLocal());
    // restore env vars (probably not necessary)
    if (ACS_LOG_STDOUT_ORIGINAL != null) {
        System.setProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL_LOCAL, ACS_LOG_STDOUT_ORIGINAL);
    }
    if (ACS_LOG_REMOTE_ORIGINAL != null) {
        System.setProperty(LogConfig.PROPERTYNAME_MIN_LOG_LEVEL, ACS_LOG_REMOTE_ORIGINAL);
    }
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) AcsLogLevelDefinition(alma.acs.logging.level.AcsLogLevelDefinition) LoggingConfig(alma.maci.loggingconfig.LoggingConfig)

Example 5 with LoggingConfig

use of alma.maci.loggingconfig.LoggingConfig in project ACS by ACS-Community.

the class TestLogLevelsCompImpl method getLevels.

/////////////////////////////////////////////////////////////
// Implementation of TestLogLevelsCompOperations
/////////////////////////////////////////////////////////////
public int[] getLevels() throws CouldntPerformActionEx {
    //m_logger.info("getLevels called...");
    /*
    	 *  alma.maci.loggingconfig.LoggingConfig got generated from LoggingConfig.xsd and
    	 *  it contains the "default values" (also called "hardcoded").
    	 */
    levels = new int[5];
    LoggingConfig logConfig = new LoggingConfig();
    int hcMinLogLevel = Integer.parseInt(logConfig.getMinLogLevel().toString());
    int hcMinLogLevelLocal = Integer.parseInt(logConfig.getMinLogLevelLocal().toString());
    AcsLogLevel acsLevel = AcsLogLevel.getNativeLevel(m_logger.getLevel());
    int acsCoreLevel = acsLevel.getAcsLevel().value;
    // get separately the stdout and remote levels
    Handler[] handlers = m_logger.getHandlers();
    if (handlers.length != 2) {
        AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
        ex.setProperty(PROP_ASSERTION_MESSAGE, "Found " + handlers.length + " log handlers where 2 were expected.");
        throw ex.toCouldntPerformActionEx();
    //m_logger.info("Found " + handlers.length + " log handlers where 2 were expected.");
    }
    AcsLogLevel levelStdout = null;
    AcsLogLevel levelRemote = null;
    for (Handler logHandler : handlers) {
        if (logHandler instanceof StdOutConsoleHandler) {
            levelStdout = AcsLogLevel.getNativeLevel(logHandler.getLevel());
        } else if (logHandler instanceof AcsLoggingHandler) {
            levelRemote = AcsLogLevel.getNativeLevel(logHandler.getLevel());
        } else {
            AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
            ex.setProperty(PROP_ASSERTION_MESSAGE, "Handler " + logHandler + " is neither StdOutConsoleHandler nor AcsLoggingHandler");
            throw ex.toCouldntPerformActionEx();
        }
    }
    levels[0] = hcMinLogLevel;
    levels[1] = hcMinLogLevelLocal;
    levels[2] = acsCoreLevel;
    if (// should never be the case, but anyway ...
    levelRemote == null)
        levels[3] = -1;
    else
        levels[3] = levelRemote.getAcsLevel().value;
    if (// should never be the case, but anyway ...
    levelStdout == null)
        levels[4] = -1;
    else
        levels[4] = levelStdout.getAcsLevel().value;
    return levels;
}
Also used : AcsLogLevel(alma.acs.logging.AcsLogLevel) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) LoggingConfig(alma.maci.loggingconfig.LoggingConfig) StdOutConsoleHandler(alma.acs.logging.StdOutConsoleHandler) AcsLoggingHandler(alma.acs.logging.AcsLoggingHandler) AcsLoggingHandler(alma.acs.logging.AcsLoggingHandler) StdOutConsoleHandler(alma.acs.logging.StdOutConsoleHandler) Handler(java.util.logging.Handler)

Aggregations

LoggingConfig (alma.maci.loggingconfig.LoggingConfig)5 UnnamedLogger (alma.maci.loggingconfig.UnnamedLogger)4 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)2 StringReader (java.io.StringReader)2 AcsJCouldntPerformActionEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)1 AcsLogLevel (alma.acs.logging.AcsLogLevel)1 AcsLoggingHandler (alma.acs.logging.AcsLoggingHandler)1 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)1 ReaderExtractor (alma.acs.util.ReaderExtractor)1 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)1 CDBXMLErrorEx (alma.cdbErrType.CDBXMLErrorEx)1 NamedLogger (alma.maci.loggingconfig.NamedLogger)1 File (java.io.File)1 FileReader (java.io.FileReader)1 StringWriter (java.io.StringWriter)1 Handler (java.util.logging.Handler)1 CastorException (org.exolab.castor.core.exceptions.CastorException)1