Example usage for org.springframework.boot.logging LogFile get

List of usage examples for org.springframework.boot.logging LogFile get

Introduction

In this page you can find the example usage for org.springframework.boot.logging LogFile get.

Prototype

public static LogFile get(PropertyResolver propertyResolver) 

Source Link

Document

Get a LogFile from the given Spring Environment .

Usage

From source file:org.springframework.boot.actuate.endpoint.mvc.LogFileMvcEndpoint.java

private Resource getLogFileResource() {
    LogFile logFile = LogFile.get(this.environment);
    if (logFile == null) {
        logger.debug("Missing 'logging.file' or 'logging.path' properties");
        return null;
    }//from   ww w.j a  va 2s.com
    FileSystemResource resource = new FileSystemResource(logFile.toString());
    if (!resource.exists()) {
        if (logger.isWarnEnabled()) {
            logger.debug("Log file '" + resource + "' does not exist");
        }
        return null;
    }
    return resource;
}

From source file:org.springframework.boot.actuate.endpoint.web.LogFileWebEndpoint.java

private Resource getLogFileResource() {
    if (this.externalFile != null) {
        return new FileSystemResource(this.externalFile);
    }//from www .ja  v a 2  s.  c  o  m
    LogFile logFile = LogFile.get(this.environment);
    if (logFile == null) {
        logger.debug("Missing 'logging.file' or 'logging.path' properties");
        return null;
    }
    return new FileSystemResource(logFile.toString());
}

From source file:org.springframework.boot.context.logging.LoggingApplicationListener.java

/**
 * Initialize the logging system according to preferences expressed through the
 * {@link Environment} and the classpath.
 * @param environment the environment/*from www  .ja  v  a 2s  . c om*/
 * @param classLoader the classloader
 */
protected void initialize(ConfigurableEnvironment environment, ClassLoader classLoader) {
    new LoggingSystemProperties(environment).apply();
    LogFile logFile = LogFile.get(environment);
    if (logFile != null) {
        logFile.applyToSystemProperties();
    }
    initializeEarlyLoggingLevel(environment);
    initializeSystem(environment, this.loggingSystem, logFile);
    initializeFinalLoggingLevels(environment, this.loggingSystem);
    registerShutdownHookIfNecessary(environment, this.loggingSystem);
}

From source file:org.springframework.boot.logging.LoggingApplicationListener.java

private void initializeSystem(ConfigurableEnvironment environment, LoggingSystem system) {
    LoggingInitializationContext initializationContext = new LoggingInitializationContext(environment);
    LogFile logFile = LogFile.get(environment);
    String logConfig = environment.getProperty(CONFIG_PROPERTY);
    if (ignoreLogConfig(logConfig)) {
        system.initialize(initializationContext, null, logFile);
    } else {/* ww w  .j a  v a  2s.co m*/
        try {
            ResourceUtils.getURL(logConfig).openStream().close();
            system.initialize(initializationContext, logConfig, logFile);
        } catch (Exception ex) {
            // NOTE: We can't use the logger here to report the problem
            System.err.println(
                    "Logging system failed to initialize " + "using configuration from '" + logConfig + "'");
            ex.printStackTrace(System.err);
            throw new IllegalStateException(ex);
        }
    }
}