diff --git a/server/src/main/java/io/druid/server/log/FileRequestLogger.java b/server/src/main/java/io/druid/server/log/FileRequestLogger.java index 67780c77cbf2..88a61bd31224 100644 --- a/server/src/main/java/io/druid/server/log/FileRequestLogger.java +++ b/server/src/main/java/io/druid/server/log/FileRequestLogger.java @@ -32,6 +32,7 @@ import org.joda.time.MutableDateTime; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; @@ -69,10 +70,7 @@ public void start() synchronized (lock) { currentDay = mutableDateTime.toDateTime(); - fileWriter = new OutputStreamWriter( - new FileOutputStream(new File(baseDir, currentDay.toString("yyyy-MM-dd'.log'")), true), - Charsets.UTF_8 - ); + fileWriter = getFileWriter(); } long nextDay = currentDay.plusDays(1).getMillis(); Duration delay = new Duration(nextDay - new DateTime().getMillis()); @@ -90,10 +88,7 @@ public ScheduledExecutors.Signal call() synchronized (lock) { currentDay = currentDay.plusDays(1); CloseQuietly.close(fileWriter); - fileWriter = new OutputStreamWriter( - new FileOutputStream(new File(baseDir, currentDay.toString()), true), - Charsets.UTF_8 - ); + fileWriter = getFileWriter(); } } catch (Exception e) { @@ -110,6 +105,13 @@ public ScheduledExecutors.Signal call() } } + private OutputStreamWriter getFileWriter() throws FileNotFoundException { + return new OutputStreamWriter( + new FileOutputStream(new File(baseDir, currentDay.toString("yyyy-MM-dd'.log'")), true), + Charsets.UTF_8 + ); + } + @LifecycleStop public void stop() {