在 express-gateway 中,我想记录 consumerid,我得到示例 ${req.ip} 工作正常但我如何引用 eg 特定元素,如 consumerId?

In express-gateway i want to log consumerid, I get the example ${req.ip} works fine but how do i reference the eg specific elements like consumerId?

如何引用 consumerId 以登录 express-gateway - 是否在任何地方记录了特定于 eg 的 'elements'?

mytest:
 apiEndpoints:
  - test
 policies:
  - log:
     action:
       message: ${req.consumerId} ${req.ip} ${req.method} ${req.originalUrl}
  - key-auth:
  - proxy:
     action:
      serviceEndpoint: testscore
      changeOrigin: true
      stripPath: true

给我一个 Null 响应

它们都放在egContext包对象中。

req.egContext.consumerId

我可以使用以下方法获取消费者 ID: ${egContext.consumer.id} 请注意,它仅在授权策略后可用,例如:oauth2