aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/logger/impl/FileLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/romjaki/logger/impl/FileLogger.java')
-rw-r--r--src/main/java/de/romjaki/logger/impl/FileLogger.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/de/romjaki/logger/impl/FileLogger.java b/src/main/java/de/romjaki/logger/impl/FileLogger.java
new file mode 100644
index 0000000..b7c8f3f
--- /dev/null
+++ b/src/main/java/de/romjaki/logger/impl/FileLogger.java
@@ -0,0 +1,27 @@
+package de.romjaki.logger.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class FileLogger extends StreamLogger {
+ public FileLogger(String name, File file) throws IOException {
+ super(name, new FileOutputStream(createFile(file)));
+ }
+
+ public FileLogger(File file) throws IOException {
+ super(new FileOutputStream(createFile(file)));
+ }
+
+ private static File createFile(File file) throws IOException {
+ if (!file.getParentFile().exists()) {
+ file.getParentFile().mkdirs();
+ }
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ return file;
+ }
+
+
+}