如何为 AsyncNCSARequestLog 设置日志区域和延迟

How to set log locale and latency for AsyncNCSARequestLog

虽然 AsyncNCSARequestLog 已弃用,但我应该将其替换为 CustomRequestLog

密码是:

AsyncNCSARequestLog log = new AsyncNCSARequestLog(filename);
log.setAppend(true);
log.setLogLatency(true);
log.setRetainDays(retainDays);
log.setLogLocale(Locale.ENGLISH);

应该是:

AsyncRequestLogWriter writer = new AsyncRequestLogWriter(filename, new BlockingArrayQueue<>(size));
writer.setAppend(true);
writer.setRetainDays(retainDays);
CustomRequestLog log = new CustomRequestLog(writer, CustomRequestLog.EXTENDED_NCSA_FORMAT);

但是没有为 CustomRequestLogAsyncRequestLogWriter 设置日志区域和延迟的选项。 我该如何设置它们?

更新:

以下设置已消失:

AsyncNCSARequestLog log = new AsyncNCSARequestLog(filename, new BlockingArrayQueue<>());
log.setLogDateFormat(format);
log.setExtended(true);
log.setLogLocale(Locale.ENGLISH);
log.setLogCookies(true);
log.setLogLatency(true);
log.setLogServer(true);

这些都记录在 apidocs for CustomRequestLog 中。

区域设置仅用于 "time" 表示。

在格式参数中指定。

参见:%{format|timeZone|locale}t

延迟也是一个格式参数。

参见:

  • %D 以微秒为单位的延迟
  • %T 以秒为单位的延迟
  • %{UNIT}T 以您自己想要的单位表示延迟
    • %msT是毫秒
    • %usT是微秒
    • %sT是秒

您需要使用自定义格式参数,而不是 CustomRequestLog.EXTENDED_NCSA_FORMAT 的预定义标准格式(它永远不会有延迟,并且始终使用 Locale.getDefault() 作为时间表示)