public LogFileWriter(String file, boolean compressOutput) {
        try {
            $(file).file().delete();
            this.fileOutputStream = new FileOutputStream($(file).get("diagnosis.fallback.record"));
            if (compressOutput) {
                this.zipStream = new GZIPOutputStream(this.fileOutputStream);
                this.objectOutputStream = new ObjectOutputStream(this.zipStream);
            } else
                this.objectOutputStream = new ObjectOutputStream(this.fileOutputStream);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }

        // Create recording thread
        final Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                int flushCount = 0;
                while (true) {
                    try {
                        final Entry take = LogFileWriter.this.eventQueue.take();
                        LogFileWriter.this.objectOutputStream.writeUnshared(take);

                        if (flushCount++ > 50) {
                            LogFileWriter.this.objectOutputStream.reset();
                            LogFileWriter.this.objectOutputStream.flush();
                            if (LogFileWriter.this.zipStream != null) {
                                LogFileWriter.this.zipStream.flush();
                            }
                            LogFileWriter.this.fileOutputStream.flush();
                            flushCount = 0;
                        }
                    }
                    catch (InterruptedException e) {}
                    catch (IOException e) {
                         e.printStackTrace();
                     }
                 }
             }
        });
        thread.setName("LogFileWriter.serializer");
        thread.setDaemon(true);
        thread.start();

        // Registers a shutdown hook to flush the queue
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                terminate();
            }
        }));
    }