Menu

Logging — Fastify with TypeScript (part 16/18)
📰

Logging — Fastify with TypeScript (part 16/18)

DEV Community: fastify·Antonio Tripodi·8 days ago
#PwZyWmDi
#devtofastify#devto#dev#request#user
Long article (1153 words) — no AI summary yet.
Reading 0:00
15s threshold

Logging

Sixteenth chapter of the "Fastify with TypeScript" series. Good logging is essential for understanding what's happening in production. Fastify natively integrates Pino , one of the fastest JSON loggers in the Node.js ecosystem, and we switched it on back in chapter 4. Let's look at what it has been writing all along, and make three improvements.

What you already have

Start the server, create a user with the curl command from chapter 13, and read the terminal. Every request produces at least two lines:

{ "level" : 30 , "time" : 1795538650083 , "pid" : 2091 , "hostname" : "vm" , "reqId" : "req-1" , "req" : { "method" : "POST" , "url" : "/api/v1/users" , "host" : "localhost:3000" , "remoteAddress" : "127.0.0.1" , "remotePort" : 45864 } , "msg" : "incoming request" } { "level" : 30 , "time" : 1795538650144 , "pid" : 2091 , "hostname" : "vm" , "reqId" : "req-1" , "res" : { "statusCode" : 201 } , "responseTime" : 60.142908000000034 , "msg" : "request completed" }

Enter fullscreen mode

Exit fullscreen…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.