Example usage for org.apache.commons.logging LogConfigurationException LogConfigurationException

List of usage examples for org.apache.commons.logging LogConfigurationException LogConfigurationException

Introduction

In this page you can find the example usage for org.apache.commons.logging LogConfigurationException LogConfigurationException.

Prototype

public LogConfigurationException(Throwable cause) 

Source Link

Document

Construct a new exception with the specified cause and a derived detail message.

Usage

From source file:helma.util.Logging.java

/**
 * Get a logger for a file name. The log file is created in the
 * directory specified by the "log.dir" System property. If the
 * logname is "console" a log that writes to System.out is returned.
 *///from ww w  . j av a 2  s .c  o  m
public Log getInstance(String logname) {
    if (logname == null) {
        throw new LogConfigurationException("No logname specified!");
    }
    // normalize log name
    logname = logname.replaceAll("[^\\w\\d\\.]", "");
    if ("console".equals(logdir)) {
        if (logname.startsWith("org.mortbay."))
            return getConsoleLog().getSedatedLog();
        else
            return getConsoleLog();
    } else {
        if (logname.startsWith("org.mortbay."))
            return getFileLog(logname).getSedatedLog();
        else
            return getFileLog(logname);
    }
}

From source file:axiom.util.Logging.java

/**
 * Get a logger for a file name. The log file is created in the
 * directory specified by the "log.dir" System property. If the
 * logname is "console" a log that writes to System.out is returned.
 */// ww w .j  a v a2s .c om
public Log getInstance(String logname) {
    if (logname == null) {
        throw new LogConfigurationException("No logname specified!");
    }

    if ("console".equals(logdir)) {
        return getConsoleLog();
    } else {
        return getFileLog(logname);
    }
}

From source file:org.sakuli.utils.LoggerInitializer.java

@PostConstruct
public void initLoggerContext() {
    // properties of the LoggerContext
    List<ImmutablePair<String, String>> properties = Arrays.asList(
            new ImmutablePair<>(SakuliProperties.LOG_FOLDER,
                    sakuliProperties.getLogFolder().toAbsolutePath().toString()),
            new ImmutablePair<>(SakuliProperties.LOG_PATTERN, sakuliProperties.getLogPattern()),
            new ImmutablePair<>(SakuliProperties.LOG_LEVEL_SAKULI, sakuliProperties.getLogLevelSakuli()),
            new ImmutablePair<>(SakuliProperties.LOG_LEVEL_SAHI, sakuliProperties.getLogLevelSahi()),
            new ImmutablePair<>(SakuliProperties.LOG_LEVEL_SIKULI, sakuliProperties.getLogLevelSikuli()),
            new ImmutablePair<>(SakuliProperties.LOG_LEVEL_SPRING, sakuliProperties.getLogLevelSpring()),
            new ImmutablePair<>(SakuliProperties.LOG_LEVEL_ROOT, sakuliProperties.getLogLevelRoot()));
    //log new properties before configuring
    properties.stream().filter(p -> isNotEmpty(p.getValue()))
            .forEach(p -> logger.info("set '{}' to '{}'", p.getKey(), p.getValue()));

    //start sysout forwarding to slf4j
    SysOutOverSLF4J.sendSystemOutAndErrToSLF4J(LogLevel.INFO, LogLevel.ERROR);

    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    JoranConfigurator jc = new JoranConfigurator();
    jc.setContext(context);//w  w  w.j  a va 2  s  . c  o m
    context.reset(); // overwrite default configuration

    //put properties into the context
    properties.stream().filter(p -> isNotEmpty(p.getValue()))
            .forEach(p -> context.putProperty(p.getKey(), p.getValue()));

    //determine the config file
    String configFilePath = getConfigFileFromClasspath();
    if (configFilePath == null) {
        configFilePath = getConfigFile();
    }
    if (configFilePath == null) {
        throw new LogConfigurationException("Log configuration file '" + LOG_CONFIG_FILE_NAME
                + "' not found! Please ensure that your config folder or your classpath contains the file.");
    }
    try {
        jc.doConfigure(configFilePath);
    } catch (JoranException e) {
        throw new LogConfigurationException("unable to run the LoggerIntializer, pleae check your config!", e);
    }

    logger.info("set logback configuration file '{}'", configFilePath);
    // Jersey uses java.util.logging - bridge to slf4
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
}

From source file:org.sofun.core.api.security.SofunLoginModule.java

@Override
public boolean login() throws LoginException {

    NameCallback nameCallback = new NameCallback("Username");
    PasswordCallback passwordCallback = new PasswordCallback("Password", false);

    Callback[] callbacks = new Callback[] { nameCallback, passwordCallback };
    try {//w  w  w.  j a v a  2 s  .  c  o m
        callbackHandler.handle(callbacks);
    } catch (IOException e) {
        throw new LogConfigurationException(e);
    } catch (UnsupportedCallbackException e) {
        throw new LogConfigurationException(e);
    }

    username = nameCallback.getName();

    /*
     * Member member; try { member = getMemberService().getMember(username); } catch (CoreException e) { throw new
     * LoginException(e.getMessage()); }
     * 
     * final char[] password = passwordCallback.getPassword(); passwordCallback.clearPassword();
     * 
     * 
     * if (member.getPassword() != null) { final char[] mPassword = member.getPassword().toCharArray(); if
     * (mPassword.equals(password)) { user = new SofunPrincipal(username); roles = new SofunPrincipal[] { new
     * SofunPrincipal(SofunRoles.MEMBER) }; loginSucceeded = true; } else { loginSucceeded = false; } } else {
     * loginSucceeded = false; }
     */

    // XXX: JAAS authentication. Application level responsibility for the moment
    // This is principal is not used. We rely on oauth token exchange as well application level credentials for now.
    user = new SofunPrincipal("admin@sofungaming.com");
    roles = new SofunPrincipal[] { new SofunPrincipal(SofunRoles.MEMBER) };
    loginSucceeded = true;

    return loginSucceeded;

}