Go to the documentation of this file.
19package org.sleuthkit.autopsy.coreutils;
21import java.io.IOException;
22import java.nio.file.Paths;
23import java.util.logging.FileHandler;
24import java.util.logging.Formatter;
25import java.util.logging.Handler;
26import java.sql.Timestamp;
27import java.util.HashMap;
29import java.util.logging.LogRecord;
30import org.sleuthkit.autopsy.core.UserPreferences;
42 private static final Handler
consoleHandler =
new java.util.logging.ConsoleHandler();
54 String logFilePath = Paths.get(logDirectory,
LOG_FILE_NAME).toString();
58 fileHandler.setFormatter(
new Formatter() {
60 public String format(LogRecord record) {
61 Throwable thrown = record.getThrown();
62 String stackTrace =
"";
63 while (thrown !=
null) {
64 stackTrace += thrown.toString() +
"\n";
65 for (StackTraceElement traceElem : record.getThrown().getStackTrace()) {
66 stackTrace +=
"\t" + traceElem.toString() +
"\n";
68 thrown = thrown.getCause();
70 return (
new Timestamp(record.getMillis())).toString() +
" "
71 + record.getSourceClassName() +
" "
72 + record.getSourceMethodName() +
"\n"
73 + record.getLevel() +
": "
74 + this.formatMessage(record) +
"\n"
79 }
catch (IOException ex) {
80 throw new RuntimeException(String.format(
"Error initializing file handler for %s", logFilePath), ex);
101 logger.addHandler(newFileHandler);
160 private Logger(String name, String resourceBundleName) {
161 super(name, resourceBundleName);
162 super.setUseParentHandlers(
false);
static int getLogFileCount()
synchronized static Logger getLogger(String name)
synchronized static Logger getLogger(String name, String resourceBundleName)
static FileHandler logFileHandler
static final int LOG_SIZE
static final Map< String, Logger > namesToLoggers
static FileHandler createFileHandlerWithTraces(String logDirectory)
synchronized static void setLogDirectory(String directoryPath)
static final String LOG_ENCODING
static final Handler consoleHandler
Logger(String name, String resourceBundleName)
static final String LOG_FILE_NAME
static Version.Type getBuildType()
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.