1.1.9 • Published 6 months ago

@valuis0429/pino-mssqlserver v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

pino-mssqlserver

This package provides a pino transport for Microsoft Sql Server.

It supports batching multiple log events and writing them periodically to the database.

Installation

npm i @totalsoft/pino-mssqlserver

or

yarn add @totalsoft/pino-mssqlserver

Usage

const pino = require("pino");

const connectionString =
    'Server=myServerAddress,1333;Database=myDataBase; TrustServerCertificate=True;User Id=myUsername;Password=myPassword; MultipleActiveResultSets=true;'


const transport = pino.transport({
  target: "@totalsoft/pino-mssqlserver",
  options: {
    serviceName: "MyService.Gql",
    tableName: "__Logs",
    connectionString
  },
  level: logDatabaseMinLevel
});

const logger = pino(transport);

Options

Options for instantiating the Sql Server transport

export interface MsSqlServerTransportOptions {
  // A connection string in the Microsoft Sql Server format
  connectionString: string

  // The logs table name
  tableName: string

  // A name for the current service / application to partition the log table
  serviceName: string

  // The maximum number of log events in a batch that is written to the database (default 20)
  batchLimit?: number

  // Time interval in milliseconds at which log batches are written to the database (default 2000)
  flushInterval?: number
}

Database structure

The log table should have the following format:

CREATE TABLE [dbo].[__Logs](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Message] [nvarchar](max) NULL,
	[Level] [nvarchar](max) NULL,
	[TimeStamp] [datetime] NULL,
	[Exception] [nvarchar](max) NULL,
	[LogEvent] [nvarchar](max) NULL,
	[ServiceName] [varchar](200) NULL,
	[TenantId] [uniqueidentifier] NULL,
	[CorrelationId] [uniqueidentifier] NULL,
 CONSTRAINT [PK___Logs] PRIMARY KEY CLUSTERED ([Id] ASC)
)
1.1.9

6 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.1.1

6 months ago