Search in sources :

Example 1 with AbstractOutputStreamAppender

use of org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender in project hive by apache.

the class HttpServer method getLogDir.

String getLogDir(Configuration conf) {
    String logDir = conf.get("hive.log.dir");
    if (logDir == null) {
        logDir = System.getProperty("hive.log.dir");
    }
    if (logDir != null) {
        return logDir;
    }
    LoggerContext context = (LoggerContext) LogManager.getContext(false);
    for (Logger logger : context.getLoggers()) {
        for (Appender appender : logger.getAppenders().values()) {
            if (appender instanceof AbstractOutputStreamAppender) {
                OutputStreamManager manager = ((AbstractOutputStreamAppender<?>) appender).getManager();
                if (manager instanceof FileManager) {
                    String fileName = ((FileManager) manager).getFileName();
                    if (fileName != null) {
                        return fileName.substring(0, fileName.lastIndexOf('/'));
                    }
                }
            }
        }
    }
    return null;
}
Also used : AbstractOutputStreamAppender(org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender) Appender(org.apache.logging.log4j.core.Appender) OutputStreamManager(org.apache.logging.log4j.core.appender.OutputStreamManager) AbstractOutputStreamAppender(org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender) Logger(org.apache.logging.log4j.core.Logger) LoggerContext(org.apache.logging.log4j.core.LoggerContext) FileManager(org.apache.logging.log4j.core.appender.FileManager)

Aggregations

Appender (org.apache.logging.log4j.core.Appender)1 Logger (org.apache.logging.log4j.core.Logger)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1 AbstractOutputStreamAppender (org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender)1 FileManager (org.apache.logging.log4j.core.appender.FileManager)1 OutputStreamManager (org.apache.logging.log4j.core.appender.OutputStreamManager)1