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);
}
}
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());
}
}
}
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);
}
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;
}
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();
}
}
Aggregations