java - 如何为 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);
但是没有为CustomRequestLog
or设置日志区域设置和延迟的选项AsyncRequestLogWriter
。我该如何设置它们?
更新:
以下设置消失了:
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);
解决方案
这些都记录在CustomRequestLog 的 apidocs 中。
语言环境仅用于“时间”表示。
这是在格式参数中指定的。
看:%{format|timeZone|locale}t
延迟也是一个格式参数。
看:
%D
以微秒为单位的延迟%T
以秒为单位的延迟%{UNIT}T
对于您自己想要的单位的延迟%msT
是毫秒%usT
是微秒%sT
是秒
您将希望使用自定义格式参数,而不是预定义的标准格式CustomRequestLog.EXTENDED_NCSA_FORMAT
(它永远不会有延迟,并且总是使用Locale.getDefault()
它的时间表示)
推荐阅读
- c++ - 使用来自不同线程的 opengl-command
- excel - 是否可以使用第三方 Excel 加载项?
- excel - 我无法使用以下代码使用 Internet Explorer 登录网站。它说运行时错误 424 - 需要对象
- swift - 用于条件绑定的 Swift Initializer 必须具有 Optional 类型,而不是 if let 语句的“Bool”错误
- mongodb - 使用 mongo-db updateMany 查询的语法错误
- sql - 在 scala 中选择几个大的 sql 后,JDBC 变得非常慢
- javascript - 为什么我面临语音 RSS api 的一些问题
- javascript - 为什么不再为我的注册表单生成 stripeTokens?
- swift - 从查询中检索 Firestore 文档计数以在 UIcollectionView 单元格计数中使用,Swift 4.0
- django - 代码应该打印特定用户的帖子,但它正在打印所有用户的帖子