2.2.0 • Published 10 months ago
gc-json-logger-nestjs v2.2.0
Logger for Structured Logging with Asynchronous Context Tracking (Stability: 2 - Stable) to log HTTP traffic in Nest.JS (Express.JS) in GKE
Enables structured logging for Nest.js application running in Google Cloud platform.
Installation
npm install --save \
gc-json-logger \
gc-json-logger-express \
gc-json-logger-nestjs
yarn add \
gc-json-logger \
gc-json-logger-express \
gc-json-logger-nestjs
View in Google Cloud Monitoring
Usage
Demo
Shell
git clone https://github.com/igrek8/gc-json-logger-nestjs
cd gc-json-logger-nestjs
npm install
npm run dev
Log Structure
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"Starting Nest application...","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"NestFactory"}}
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"LoggerModule dependencies initialized","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"InstanceLoader"}}
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"AppModule dependencies initialized","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"InstanceLoader"}}
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"AppController {/}:","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"RoutesResolver"}}
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"Mapped {/trace, POST} route","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"RouterExplorer"}}
{"severity":"INFO","time":"2022-10-08T00:00:00.000Z","message":"Nest application successfully started","logging.googleapis.com/operation":{"id":"app"},"meta":{"context":"NestApplication"}}
/* HTTP log and LoggerService use the same UUID in "logging.googleapis.com/operation" */
Use with jq
node ./server.js | jq -r '."logging.googleapis.com/operation".id as $id | { time, severity, $id, message } | join(" ")'
Trace Request-Response cycle
Trace-NestJS module adds X-Request-ID
and X-Response-ID
headers that match operation id.
1.5.0
11 months ago
2.2.0
10 months ago
2.1.0
10 months ago
2.0.0
10 months ago
1.4.0
1 year ago
1.2.0
1 year ago
1.3.0
1 year ago
1.1.0
1 year ago
1.0.1
2 years ago
1.0.0
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.1
2 years ago