Go to the documentation of this file.
19package org.sleuthkit.autopsy.apputils;
21import java.io.IOException;
22import java.nio.file.Path;
23import java.nio.file.Paths;
24import java.sql.Timestamp;
25import java.util.HashMap;
27import java.util.logging.FileHandler;
28import java.util.logging.Formatter;
29import java.util.logging.LogRecord;
30import java.util.logging.Logger;
31import org.sleuthkit.autopsy.coreutils.PlatformUtil;
47 private static final String
NEWLINE = System.lineSeparator();
48 private static final Map<String, Logger>
loggers =
new HashMap<>();
59 if (
loggers.containsKey(logName)) {
67 fileHandler.setFormatter(
new Formatter() {
69 public String format(LogRecord record) {
70 Throwable thrown = record.getThrown();
71 String stackTrace =
"";
72 while (thrown !=
null) {
73 stackTrace += thrown.toString() +
NEWLINE;
74 for (StackTraceElement traceElem : record.getThrown().getStackTrace()) {
75 stackTrace +=
"\t" + traceElem.toString() +
NEWLINE;
77 thrown = thrown.getCause();
79 return (
new Timestamp(record.getMillis())).toString() +
" "
80 + record.getSourceClassName() +
" "
81 + record.getSourceMethodName() +
NEWLINE
82 + record.getLevel() +
": "
83 + this.formatMessage(record) +
NEWLINE
87 logger.addHandler(fileHandler);
88 logger.setUseParentHandlers(
false);
89 }
catch (SecurityException | IOException ex) {
90 throw new RuntimeException(String.format(
"Error initializing file handler for %s", logFilePath), ex);
synchronized static Logger getLogger(String logName)
static final Map< String, Logger > loggers
static final int LOG_SIZE
static final String NEWLINE
static final int LOG_FILE_COUNT
synchronized static Logger getLogger(String name)
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.