Gathering detailed insights and metrics for @jasonsoft/nestjs-seq
Gathering detailed insights and metrics for @jasonsoft/nestjs-seq
Gathering detailed insights and metrics for @jasonsoft/nestjs-seq
Gathering detailed insights and metrics for @jasonsoft/nestjs-seq
🐷 Seq logging module for Nest framework (node.js)
npm install @jasonsoft/nestjs-seq
Typescript
Module System
Node Version
NPM Version
TypeScript (98.85%)
JavaScript (1.15%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
185 Stars
61 Commits
7 Forks
8 Watchers
2 Branches
1 Contributors
Updated on Jul 02, 2025
Latest Version
2.1.3
Package Id
@jasonsoft/nestjs-seq@2.1.3
Unpacked Size
111.84 kB
Size
23.92 kB
File Count
46
NPM Version
10.2.4
Node Version
20.11.1
Published on
Apr 24, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
🐷 Seq logging module for Nest framework (node.js)
1# Using npm 2$ npm i --save @jasonsoft/nestjs-seq 3 4# Using yarn 5$ yarn add @jasonsoft/nestjs-seq 6 7# Using pnpm 8$ pnpm add @jasonsoft/nestjs-seq
After successfully installing the package, proceed to integrate the SeqLoggerModule into your project's root AppModule.
1import { Module } from '@nestjs/common';
2import { AppController } from './app.controller';
3import { AppService } from './app.service';
4/**
5 * Import the SeqLoggerModule into the root AppModule to enable centralized logging.
6 * This module is configured to connect to a Seq server for log aggregation and analysis.
7 * It is essential for monitoring and debugging applications by collecting and storing logs.
8 * Updated by Jason.Song (成长的小猪) on 2024/04/21
9 * Added by Jason.Song (成长的小猪) on 2021/09/08
10 */
11import { SeqLoggerModule } from '@jasonsoft/nestjs-seq';
12
13@Module({
14 imports: [
15 /**
16 * Import and configure the SeqLoggerModule using the .forRoot() method.
17 * This method initializes the module with server-specific configurations,
18 * allowing for centralized management of log data across the application.
19 * Updated by Jason.Song (成长的小猪) on 2024/04/21
20 * Added by Jason.Song (成长的小猪) on 2021/09/08
21 */
22 SeqLoggerModule.forRoot({
23 /** Specifies the URL of the Seq server to which logs should be sent. */
24 serverUrl: 'http://localhost:5341',
25 /** Provides the API Key required for authenticating with the Seq server. */
26 apiKey: 'K7iUhZ9OSp6oX5EOCfPt',
27 /** Optional additional metadata properties */
28 extendMetaProperties: {
29 /** Defines a custom service name for the logs, aiding in their categorization and filtering.
30 * This name helps in identifying logs related to this service in a mixed-service environment.
31 */
32 serviceName: 'product-service',
33 },
34 /** For more configuration details, see the "Seq Logger Options Documentation" section below. */
35 }),
36 ],
37 controllers: [AppController],
38 providers: [AppService],
39})
40export class AppModule {}
1// Import ConfigModule to manage application configuration through environment variables. 2import { ConfigModule, ConfigService } from '@nestjs/config'; 3import { SeqLoggerModule } from '@jasonsoft/nestjs-seq'; 4 5@Module({ 6 imports: [ 7 ConfigModule.forRoot(), 8 /** 9 * Asynchronously configure the SeqLoggerModule using the forRootAsync() method. 10 * This method allows module options to be passed asynchronously, leveraging factory providers 11 * that can be asynchronous and inject dependencies such as ConfigService. 12 * Updated by Jason.Song (成长的小猪) on 2024/04/21 13 * Added by Jason.Song (成长的小猪) on 2021/10/20 14 */ 15 SeqLoggerModule.forRootAsync({ 16 imports: [ConfigModule], 17 useFactory: async (configService: ConfigService) => ({ 18 /** Specifies the HTTP/S endpoint address of the Seq server for log transmission. */ 19 serverUrl: configService.get('SEQ_SERVER_URL'), 20 /** Provides the API Key required for authenticating with the Seq server. */ 21 apiKey: configService.get('SEQ_API_KEY'), 22 /** Optional additional metadata properties to enhance log categorization and filtering. */ 23 extendMetaProperties: { 24 /** Custom service name for the logs to assist in their categorization and filtering within a multi-service environment. */ 25 serviceName: configService.get('SEQ_SERVICE_NAME'), 26 }, 27 /** For more configuration details, see the "Seq Logger Options Documentation" section below. */ 28 }), 29 inject: [ConfigService], 30 }), 31 ], 32 controllers: [AppController], 33 providers: [AppService], 34}) 35export class AppModule {}
Please refer to the Seq Logger Options Documentation for detailed explanations of the configuration options available for the Seq Logger. For immediate access to the document, click here.
1import { Controller, Get } from '@nestjs/common'; 2import { AppService } from './app.service'; 3/** 4 * Import the SeqLogger for structured logging. 5 * This logger allows for easy tracking and querying of log data. 6 * Updated by Jason.Song (成长的小猪) on 2024/04/21 7 * Added by Jason.Song (成长的小猪) on 2021/09/08 8 */ 9import { SeqLogger } from '@jasonsoft/nestjs-seq'; 10 11@Controller() 12export class AppController { 13 constructor( 14 /** 15 * Inject the Seq Logger service for structured logging. 16 * This service provides methods to log various levels of information (info, debug, error). 17 * Updated by Jason.Song (成长的小猪) on 2024/04/21 18 * Added by Jason.Song (成长的小猪) on 2021/09/08 19 */ 20 private readonly logger: SeqLogger, 21 private readonly appService: AppService, 22 ) {} 23 24 @Get() 25 getHello(): string { 26 this.logger.info('getHello - start', AppController.name); 27 28 const result = this.appService.getHello(); 29 this.logger.debug( 30 `Retrieving result from {name}`, 31 { 32 name: 'AppService', 33 result, 34 note: 'The message template function is used here', 35 }, 36 AppController.name, 37 ); 38 39 try { 40 throw new Error('Oops! Something whimsically wrong just happened!'); 41 } catch (error: any) { 42 this.logger.error(error, AppController.name); 43 this.logger.error( 44 'The error has been successfully captured and handled!', 45 error, 46 AppController.name, 47 ); 48 49 return result; 50 } 51 } 52} 53
Seq is a powerful centralized logging system. Explore the logs we have gathered:
This section describes how to integrate Nest system console logging with Seq through a custom console logger. To set up this integration, follow the steps below:
1import { NestFactory } from '@nestjs/core'; 2import { AppModule } from './app.module'; 3/** 4 * Import the ConsoleSeqLogger to extend the built-in logger for supporting Seq. 5 * Added by Jason.Song (成长的小猪) on 2021/09/24 6 */ 7import { ConsoleSeqLogger } from '@jasonsoft/nestjs-seq'; 8 9async function bootstrap() { 10 /** 11 * Set bufferLogs to true to buffer all logs until the ConsoleSeqLogger is attached. 12 * This ensures that logs are captured during the application initialization. 13 * If initialization fails, Nest will use the default ConsoleLogger to output error messages. 14 */ 15 const app = await NestFactory.create(AppModule, { 16 bufferLogs: true, 17 }); 18 19 /** 20 * Use the ConsoleSeqLogger to extend the built-in logger functionality. 21 */ 22 app.useLogger(app.get(ConsoleSeqLogger)); 23 24 await app.listen(3000); 25} 26bootstrap();
This setup allows your NestJS application to log directly to Seq, providing a centralized logging solution.
Seq Interface Overview showing the integration of Nest System Console Logging with Seq.
For a practical implementation example, visit the nestjs-seq-example repository on GitHub.
No vulnerabilities found.
No security vulnerabilities found.