Search in sources :

Example 16 with UnnamedLogger

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

the class LogConfig method configureNamedLoggerLevelsFromProperties.

/**
	 * Reads the property <code>ACS.log.minlevel.namedloggers</code> (name defined as {@link #PROPERTYNAME_NAMED_LOGGER_LEVELS}) 
	 * and, if the property is defined, sets the respective named logger levels. Prior values are lost.
	 */
private void configureNamedLoggerLevelsFromProperties() {
    String propVal = System.getProperty(PROPERTYNAME_NAMED_LOGGER_LEVELS);
    if (propVal != null) {
        try {
            for (String levelDef : propVal.split(":")) {
                String[] levelDefSplit = levelDef.split("=");
                try {
                    String loggerName = levelDefSplit[0].trim();
                    String[] levels = levelDefSplit[1].split(",");
                    UnnamedLogger loggerConfig = new UnnamedLogger();
                    loggerConfig.setMinLogLevelLocal(AcsLogLevelDefinition.xsdLevelFromInteger(Integer.parseInt(levels[0])));
                    loggerConfig.setMinLogLevel(AcsLogLevelDefinition.xsdLevelFromInteger(Integer.parseInt(levels[1])));
                    storeNamedLoggerConfig(loggerName, new LockableUnnamedLogger(loggerConfig));
                    log(Level.INFO, "Set named logger levels from property. Name=" + loggerName + " local=" + loggerConfig.getMinLogLevelLocal() + " remote=" + loggerConfig.getMinLogLevel(), null);
                } catch (Exception ex) {
                    log(Level.WARNING, "Failed to process named logger level definition '" + levelDef + "' given in property '" + PROPERTYNAME_NAMED_LOGGER_LEVELS + "'. ", ex);
                }
            }
        } catch (Exception ex) {
            log(Level.WARNING, "Failed to process named loggers from property " + PROPERTYNAME_NAMED_LOGGER_LEVELS, ex);
        }
    } else {
        log(Level.FINEST, PROPERTYNAME_NAMED_LOGGER_LEVELS + " not defined.", null);
    }
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) XPathExpressionException(javax.xml.xpath.XPathExpressionException) TransformerException(javax.xml.transform.TransformerException) CastorException(org.exolab.castor.core.exceptions.CastorException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 17 with UnnamedLogger

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

the class AcsLogger method configureLogging.

/**
     * Callback method, configures this logger from the data in logConfig.
     * @see alma.acs.logging.config.LogConfigSubscriber#configureLogging(alma.acs.logging.config.LogConfig)
     */
public void configureLogging(LogConfig newLogConfig) {
    if (newLogConfig == null) {
        throw new IllegalArgumentException("newLogConfig must not be null");
    }
    logConfig = newLogConfig;
    try {
        UnnamedLogger config = logConfig.getNamedLoggerConfig(getLoggerName());
        if (DEBUG) {
            System.out.println("*** AcsLogger#configureLogging: name=" + getLoggerName() + " minLevel=" + config.getMinLogLevel() + " minLevelLocal=" + config.getMinLogLevelLocal());
        }
        configureLevels(config);
    } catch (Exception e) {
        log(Level.INFO, "Failed to configure logger.", e);
    }
    // forward log level to optional JacORB filter
    // Perhaps this dependency is too dirty, then we need a more general
    // filter registration mechanism parallel to what the JDK foresees.
    Filter logFilter = getFilter();
    if (logFilter != null && logFilter instanceof JacORBFilter) {
        ((JacORBFilter) logFilter).setLogLevel(getLevel());
    }
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) JacORBFilter(alma.acs.logging.adapters.JacORBFilter) Filter(java.util.logging.Filter) JacORBFilter(alma.acs.logging.adapters.JacORBFilter)

Example 18 with UnnamedLogger

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

the class DALImpl method get_logLevels.

/**
	 * Gets log levels for a particular named logger. If the returned field
	 * LogLevels.useDefault is true, then the logger uses the default levels,
	 * see get_default_logLevels(); otherwise the returned local and remote
	 * levels apply.
	 * <p>
	 * For possible convenience, the default levels are returned in addition to 
	 * setting {@link LogLevels#useDefault} to <code>true</code>.
	 */
public LogLevels get_logLevels(String logger_name) throws LoggerDoesNotExistEx {
    UnnamedLogger xsdLevels = logConfig.getNamedLoggerConfig(logger_name);
    boolean useDefault = !logConfig.hasCustomConfig(logger_name);
    LogLevels ret = AcsLogLevelDefinition.createIdlLogLevelsFromXsd(useDefault, xsdLevels);
    return ret;
}
Also used : UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) LogLevels(alma.Logging.LoggingConfigurablePackage.LogLevels)

Example 19 with UnnamedLogger

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

the class DALImpl method set_logLevels.

/**
	 * Sets log levels for a particular named logger. If levels.useDefault is
	 * true, then the logger will be reset to using default levels; otherwise it
	 * will use the supplied local and remote levels.
	 */
public void set_logLevels(String logger_name, LogLevels levels) throws LoggerDoesNotExistEx, IllegalLogLevelsEx {
    if (levels.useDefault) {
        logConfig.clearNamedLoggerConfig(logger_name);
    } else {
        try {
            UnnamedLogger config = AcsLogLevelDefinition.createXsdLogLevelsFromIdl(levels);
            logConfig.setNamedLoggerConfig(logger_name, config);
        } catch (AcsJIllegalArgumentEx ex) {
            //throw ex.toIllegalArgumentEx();
            IllegalLogLevelsEx ille = new IllegalLogLevelsEx(ex.getErrorDesc());
            throw ille;
        }
    }
}
Also used : IllegalLogLevelsEx(alma.Logging.IllegalLogLevelsEx) UnnamedLogger(alma.maci.loggingconfig.UnnamedLogger) AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)

Aggregations

UnnamedLogger (alma.maci.loggingconfig.UnnamedLogger)19 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)6 IllegalLogLevelsEx (alma.Logging.IllegalLogLevelsEx)6 LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)6 LoggingConfig (alma.maci.loggingconfig.LoggingConfig)4 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)3 LogConfig (alma.acs.logging.config.LogConfig)2 LockableUnnamedLogger (alma.acs.logging.config.LogConfig.LockableUnnamedLogger)2 StringReader (java.io.StringReader)2 CastorException (org.exolab.castor.core.exceptions.CastorException)2 JacORBFilter (alma.acs.logging.adapters.JacORBFilter)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 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Filter (java.util.logging.Filter)1