Handler (@NotNull String logPath) { try { @NonNls FileHandler appender = new FileHandler(logPath, false); appender.setLevel(Level.ALL); appender.setFormatter(new Formatter() { @Override public String format(LogRecord record) { String level = record.getLevel() == Level.WARNING ? "WARN" : record.getLevel().toString(); String result = String.format("%1$td/%1$tm %1$tT %2$5s %3$s - %4$s%5$s", record.getMillis(), level, record.getLoggerName(), record.getMessage(), System.lineSeparator()); Throwable thrown = record.getThrown(); if (thrown != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); thrown.printStackTrace(pw); return result + sw; } return result; } }); return appender; } catch (IOException e) { //noinspection UseOfSystemOutOrSystemErr System.err.println("Error creating log file: " + e.getMessage()); return new ConsoleHandler(); } }