private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException { this.directory = directory.getCanonicalFile(); archiveFormat = new SimpleDateFormatThreadLocal(archivePattern); fileFormat = new SimpleDateFormatThreadLocal(filePattern); final Date now = new Date(); currentArchive = new File(directory, archiveFormat.get().format(now)).getCanonicalFile(); currentFile = new File(directory, fileFormat.get().format(now)).getCanonicalFile(); /* Validate the arguments */ if (!this.directory.equals(currentArchive.getParentFile())) throw new IllegalArgumentException("Archive file \"" + currentArchive + "\" is not a child of the configured directory \"" + this.directory + "\""); if (!this.directory.equals(currentFile.getParentFile())) throw new IllegalArgumentException("Access log file \"" + currentFile + "\" is not a child of the configured directory \"" + this.directory + "\""); if (currentArchive.equals(currentFile)) throw new IllegalArgumentException("Access log file and archive file point to the same file \"" + currentFile + "\""); /* Validated, we can open files */ appender = new FileAppender(currentFile, true); }
@Override StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) { if (timeStamp == null) return builder.append('-'); final SimpleDateFormat format = simpleDateFormat.get(); format.setTimeZone(timeZone); return builder.append(format.format(timeStamp)); }
RequestTimeField(String format, TimeZone zone) { this.format = format; if (format == null) { pattern = DEFAULT_PATTERN; timeZone = zone; } else { /* Check for timezone separation */ final int pos = format.lastIndexOf('@'); if ((pos < 0) || ((pos > 0) && (format.charAt(pos - 1) == '@'))) { /* There is no '@' or the last '@' is actually an '@@' */ pattern = format.replace("@@", "@"); timeZone = zone; } else if (pos == 0) { /* We have *ONLY* a time zone specified */ pattern = DEFAULT_PATTERN; timeZone = TimeZone.getTimeZone(format.substring(1)); } else { /* We have both format and time zone */ pattern = format.substring(0, pos).replace("@@", "@"); timeZone = TimeZone.getTimeZone(format.substring(pos + 1)); } } /* Get our simple date format */ simpleDateFormat = new SimpleDateFormatThreadLocal(pattern); }