@Test
  public void buildAppender() throws Exception {
    File logsDir = temp.newFolder();
    CeFileAppenderFactory factory = new CeFileAppenderFactory(logsDir);

    FileAppender underTest = factory.buildAppender(new LoggerContext(), "uuid_1.log");

    assertThat(new File(underTest.getFile())).isEqualTo(new File(logsDir, "uuid_1.log"));
  }
  @Override
  public void openFile(String fname) throws IOException {
    File file = new File(fname);
    if (file.exists()) {
      truncate(file);
    }

    super.openFile(fname);
  }
  static LoggerContext buildLoggerContext(String filename, boolean safetyMode) {
    LoggerContext loggerContext = new LoggerContext();

    FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();

    PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
    patternLayout.setPattern("%5p %c - %m%n");
    patternLayout.setContext(loggerContext);
    patternLayout.start();

    fa.setEncoder(patternLayout);
    fa.setFile(filename);
    fa.setAppend(false);
    fa.setPrudent(safetyMode);
    fa.setContext(loggerContext);
    fa.start();

    ch.qos.logback.classic.Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    root.addAppender(fa);

    return loggerContext;
  }