自定义 Weblogic HTTP 扩展日志记录格式

问题描述 投票:0回答:2

目前在我的 weblogic 服务器中我已启用 HTTP 日志记录。以下是当前配置。

格式为“扩展”。

扩展日志格式字段为“日期时间 cs-method cs-uri sc-status time-taken c-ip”

所以在 access.log 中,日志就像这样

当前

2018-01-18      11:39:19        GET     /test/service       200     1.406 127.0.0.1
2018-01-18      11:39:19        POST    /test/service      200 0.169    127.0.0.1

我想更改 access.log 中的日志记录格式,就像下面提到的键值对一样:

预计

date=2018-01-18      time=11:39:19        method=GET     uri=/test/service       status=200     duration=1.406      client_ip=127.0.0.1
date=2018-01-18      time=11:39:19        method=POST    uri=/test/service       status=200     duration=0.169      client_ip=127.0.0.1

是否可以按照上述修改访问日志格式?

如果可能,如何在扩展日志格式字段中添加这些键?

weblogic 服务器版本:12.1.2 和 12.2.1

问候

纳兹

logging weblogic weblogic12c access-log
2个回答
0
投票

一切都在这个文档中进行了解释。 您可以创建自己的自定义字段并让它们显示您需要的任何内容。


0
投票

是的,你可以,但你需要编写一些 Java 代码。

long getInvokeTime();
返回
currentTimeMillis()
的开始时间。

要获取 servlet 将响应发送到客户端所花费的时间长度,请使用以下代码:

long milsec = System.currentTimeMillis() - metrics.getInvokeTime();

Float sec = new Float(milsec / 1000.0);
© www.soinside.com 2019 - 2024. All rights reserved.