use of org.apache.log4j.FileAppender in project hbase by apache.
the class LogMonitoring method getActiveLogFiles.
public static Set<File> getActiveLogFiles() throws IOException {
Set<File> ret = Sets.newHashSet();
Appender a;
@SuppressWarnings("unchecked") Enumeration<Appender> e = Logger.getRootLogger().getAllAppenders();
while (e.hasMoreElements()) {
a = e.nextElement();
if (a instanceof FileAppender) {
FileAppender fa = (FileAppender) a;
String filename = fa.getFile();
ret.add(new File(filename));
}
}
return ret;
}
use of org.apache.log4j.FileAppender in project cpsolver by UniTime.
the class Test method setupLogging.
/**
* Setup log4j logging
*
* @param logFile log file
* @param debug true if debug messages should be logged (use -Ddebug=true to enable debug message)
*/
public static void setupLogging(File logFile, boolean debug) {
Logger root = Logger.getRootLogger();
ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
console.setThreshold(Level.INFO);
root.addAppender(console);
if (logFile != null) {
try {
FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
file.setThreshold(Level.DEBUG);
root.addAppender(file);
} catch (IOException e) {
sLogger.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
}
}
if (!debug)
root.setLevel(Level.INFO);
}
use of org.apache.log4j.FileAppender in project cpsolver by UniTime.
the class Test method setupLogging.
/**
* Setup log4j logging
*
* @param logFile log file
*/
public static void setupLogging(File logFile) {
Logger root = Logger.getRootLogger();
ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
console.setThreshold(Level.INFO);
root.addAppender(console);
if (logFile != null) {
try {
FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
file.setThreshold(Level.DEBUG);
root.addAppender(file);
} catch (IOException e) {
sLog.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
}
}
}
use of org.apache.log4j.FileAppender in project intellij-community by JetBrains.
the class Runner method initLogger.
public static void initLogger() {
if (logger == null) {
long requiredFreeSpace = 1000000;
String logFolder = getDir(requiredFreeSpace);
FileAppender update = new FileAppender();
update.setFile(new File(logFolder, "idea_updater.log").getAbsolutePath());
update.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
update.setThreshold(Level.ALL);
update.setAppend(true);
update.activateOptions();
FileAppender updateError = new FileAppender();
updateError.setFile(new File(logFolder, "idea_updater_error.log").getAbsolutePath());
updateError.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
updateError.setThreshold(Level.ERROR);
updateError.setAppend(false);
updateError.activateOptions();
logger = Logger.getLogger("com.intellij.updater");
logger.addAppender(updateError);
logger.addAppender(update);
logger.setLevel(Level.ALL);
logger.info("--- Updater started ---");
}
}
use of org.apache.log4j.FileAppender in project symmetric-ds by JumpMind.
the class SnapshotUtil method findSymmetricLogFile.
@SuppressWarnings("unchecked")
public static Map<File, Layout> findSymmetricLogFile() {
Enumeration<Appender> appenders = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
while (appenders.hasMoreElements()) {
Appender appender = appenders.nextElement();
if (appender instanceof FileAppender) {
FileAppender fileAppender = (FileAppender) appender;
if (fileAppender != null) {
File file = new File(fileAppender.getFile());
if (file != null && file.exists()) {
Map<File, Layout> matches = new HashMap<File, Layout>();
matches.put(file, fileAppender.getLayout());
return matches;
}
}
}
}
return null;
}
Aggregations