Search in sources :

Example 11 with FileHandler

use of java.util.logging.FileHandler in project geode by apache.

the class AbstractLauncher method initLogger.

void initLogger() {
    try {
        this.logger.addHandler(new FileHandler(SystemUtils.CURRENT_DIRECTORY.concat("debug.log")));
        this.logger.setLevel(Level.ALL);
        this.logger.setUseParentHandlers(true);
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.err.flush();
        throw new RuntimeException(e);
    }
}
Also used : IOException(java.io.IOException) FileHandler(java.util.logging.FileHandler)

Example 12 with FileHandler

use of java.util.logging.FileHandler in project geode by apache.

the class LogWrapper method configure.

public void configure(GfshConfig config) {
    if (config.isLoggingEnabled()) {
        try {
            FileHandler fileHandler = new FileHandler(config.getLogFilePath(), config.getLogFileSizeLimit(), config.getLogFileCount(), true);
            fileHandler.setFormatter(new GemFireFormatter());
            fileHandler.setLevel(config.getLogLevel());
            logger.addHandler(fileHandler);
            logger.setLevel(config.getLogLevel());
        } catch (SecurityException e) {
            addDefaultConsoleHandler(logger, e.getMessage(), config.getLogFilePath());
        } catch (IOException e) {
            addDefaultConsoleHandler(logger, e.getMessage(), config.getLogFilePath());
        }
    }
}
Also used : IOException(java.io.IOException) FileHandler(java.util.logging.FileHandler)

Example 13 with FileHandler

use of java.util.logging.FileHandler in project ignite by apache.

the class JavaLogger method fileName.

/** {@inheritDoc} */
@Nullable
@Override
public String fileName() {
    JavaLoggerFileHandler gridFileHnd = findHandler(impl, JavaLoggerFileHandler.class);
    if (gridFileHnd != null)
        return gridFileHnd.fileName();
    FileHandler fileHnd = findHandler(impl, FileHandler.class);
    return fileName(fileHnd);
}
Also used : FileHandler(java.util.logging.FileHandler) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with FileHandler

use of java.util.logging.FileHandler in project logging-log4j2 by apache.

the class FileAppenderParamsBenchmark method setUp.

@Setup
public void setUp() throws Exception {
    System.setProperty("log4j.configurationFile", "log4j2-perf.xml");
    System.setProperty("log4j.configuration", "log4j12-perf.xml");
    System.setProperty("logback.configurationFile", "logback-perf.xml");
    deleteLogFiles();
    log4j2Logger = LogManager.getLogger(getClass());
    log4j2RandomLogger = LogManager.getLogger("TestRandom");
    slf4jLogger = LoggerFactory.getLogger(getClass());
    log4j1Logger = org.apache.log4j.Logger.getLogger(getClass());
    julFileHandler = new FileHandler("target/testJulLog.log");
    julLogger = java.util.logging.Logger.getLogger(getClass().getName());
    julLogger.setUseParentHandlers(false);
    julLogger.addHandler(julFileHandler);
    julLogger.setLevel(Level.ALL);
    j = 0;
}
Also used : FileHandler(java.util.logging.FileHandler) Setup(org.openjdk.jmh.annotations.Setup)

Example 15 with FileHandler

use of java.util.logging.FileHandler in project pyramid by cheng-li.

the class App2 method main.

public static void main(Config config) throws Exception {
    Logger logger = Logger.getAnonymousLogger();
    String logFile = config.getString("output.log");
    FileHandler fileHandler = null;
    if (!logFile.isEmpty()) {
        new File(logFile).getParentFile().mkdirs();
        //todo should append?
        fileHandler = new FileHandler(logFile, true);
        java.util.logging.Formatter formatter = new SimpleFormatter();
        fileHandler.setFormatter(formatter);
        logger.addHandler(fileHandler);
        logger.setUseParentHandlers(false);
    }
    logger.info(config.toString());
    new File(config.getString("output.folder")).mkdirs();
    if (config.getBoolean("train")) {
        train(config, logger);
        if (config.getString("predict.target").equals("macroFMeasure")) {
            logger.info("predict.target=macroFMeasure,  user needs to run 'tune' before predictions can be made. " + "Reports will be generated after tuning.");
        } else {
            if (config.getBoolean("train.generateReports")) {
                report(config, config.getString("input.trainData"), logger);
            }
        }
        File metaDataFolder = new File(config.getString("input.folder"), "meta_data");
        config.store(new File(metaDataFolder, "saved_config_app2"));
    }
    if (config.getBoolean("tune")) {
        tuneForMacroF(config, logger);
        File metaDataFolder = new File(config.getString("input.folder"), "meta_data");
        Config savedConfig = new Config(new File(metaDataFolder, "saved_config_app2"));
        if (savedConfig.getBoolean("train.generateReports")) {
            report(config, config.getString("input.trainData"), logger);
        }
    }
    if (config.getBoolean("test")) {
        report(config, config.getString("input.testData"), logger);
    }
    if (fileHandler != null) {
        fileHandler.close();
    }
}
Also used : Config(edu.neu.ccs.pyramid.configuration.Config) SimpleFormatter(java.util.logging.SimpleFormatter) Logger(java.util.logging.Logger) File(java.io.File) FileHandler(java.util.logging.FileHandler)

Aggregations

FileHandler (java.util.logging.FileHandler)43 IOException (java.io.IOException)19 File (java.io.File)12 SimpleFormatter (java.util.logging.SimpleFormatter)9 Handler (java.util.logging.Handler)7 LogRecord (java.util.logging.LogRecord)5 ConsoleHandler (java.util.logging.ConsoleHandler)4 Formatter (java.util.logging.Formatter)3 Logger (java.util.logging.Logger)3 Config (edu.neu.ccs.pyramid.configuration.Config)2 Setup (org.openjdk.jmh.annotations.Setup)2 FileLogFormatter (org.opensolaris.opengrok.logger.formatter.FileLogFormatter)2 LogFormatter (com.facebook.buck.log.LogFormatter)1 HumanReadableException (com.facebook.buck.util.HumanReadableException)1 NaviLogFormatter (com.google.security.zynamics.binnavi.Log.NaviLogFormatter)1 FileReadException (com.google.security.zynamics.binnavi.config.FileReadException)1 RcvrExceptionHandler (edu.cmu.cs.hcii.cogtool.ui.RcvrExceptionHandler)1 RuntimeIOException (edu.stanford.nlp.io.RuntimeIOException)1 NewlineLogFormatter (edu.stanford.nlp.util.logging.NewlineLogFormatter)1 FileInputStream (java.io.FileInputStream)1