private static FileAppender initFileAppender() { FileAppender appender = new FileAppender(); appender.setFileName(ctx.getString(R.string.log_file_externe)); appender.setAppend(true); appender.setFormatter(getPatternPerso()); return appender; }
/** * Sets the context for the logger which will add support for logging to file * * @param c context of the logger */ public synchronized void setContext(Context c) { if (mFileAppender == null) { PatternFormatter formatter = new PatternFormatter(); /* * Format date message throwable */ formatter.setPattern("%d{ISO8601} %m %T"); /* * Always write logs to file */ mFileAppender = new FileAppender(c); mFileAppender.setFormatter(formatter); File logFile = mFileAppender.getLogFile(); boolean append = true; if (logFile != null) { if (logFile.length() > 1024 * 1024) { /* * The log file is > 1MB, start a new one */ append = false; } } mFileAppender.setAppend(append); mMicrologLogger.addAppender(mFileAppender); } }