expressjs / morgan

HTTP request logger middleware for node.js
MIT License
7.95k stars 536 forks source link

`User: ':remote-user'` does not show logged-in user but `-` #283

Open khteh opened 1 year ago

khteh commented 1 year ago

I am using SPDY server for HTTP/2 for my React.JS / Next.JS application. Unfortunately this solution needs to use Express.JS and therefore this is what I do to have request logging:

    const format = json({
      IP: ':remote-addr',
      User: ':remote-user',
      Timestamp: ':date[clf]',
      Method: ':method',
      Path: ':url',
      Protocol: 'HTTP/:http-version',
      Status: ':status',
      ContentLength: ':res[content-length]',
      Referrer: ':referrer',
      Agent: ':user-agent',
      ResponseTime: ':response-time ms',
    })

The log shows that ALL users are -. How can I have the logged in user in that logging field?