Skip to content

Is there a way to disable or replacing logging? #281

Open
@oscarcalderonc

Description

@oscarcalderonc

I'm currently using serverless-http ~2.5.0 in an existing project. By default it seems it logs every request start and end, along with a big JSON containing the request information (headers, JWT, etc). I want to either be able to customize this logging or to disable entirely to be able to use another solution like Pino. An example:

ANY /my/endpoint (λ: app)
Executing (default): SELECT 1+1 AS result
{
   "level":30,
   "time":1688651877670,
   "pid":10859,
   "hostname":"123",
   "req":{
      "id":1,
      "method":"GET",
      "url":"/my/endpoint",
      "query":{
         
      },
      "params":{
         
      },
      "headers":{
         "host":"localhost:8000",
         "user-agent":"insomnia/2023.3.0",
         "authorization":"Bearer [TOKEN]",
         "accept":"*/*",
         "x-request-id":"cljr7q68s0001b1rm2xxo3dl2",
         "content-length":0
      },
      "remoteAddress":"127.0.0.1"
   },
   "res":{
      "statusCode":401,
      "headers":{
         "content-security-policy":"default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests",
         "x-dns-prefetch-control":"off",
         "expect-ct":"max-age=0",
         "x-frame-options":"SAMEORIGIN",
         "strict-transport-security":"max-age=15552000; includeSubDomains",
         "x-download-options":"noopen",
         "x-content-type-options":"nosniff",
         "x-permitted-cross-domain-policies":"none",
         "referrer-policy":"no-referrer",
         "x-xss-protection":"0",
         "vary":"Origin",
         "content-type":"application/json; charset=utf-8",
         "content-length":"25",
         "etag":"W/\"19-NLxHdTmGtBwpH6O42txxhQPNwcM\""
      }
   },
   "responseTime":709,
   "msg":"request aborted"
}
(λ: app) RequestId: cljr7q68t0002b1rmbxmw56xi  Duration: 2058.92 ms  Billed Duration: 2059 ms

How can I achieve this? The documentation is not so clear about this. It seems I can bass an options object to the serverless handler but I cannot see an option to customize or disable logging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions