datalust / winston-seq

A Winston v3 transport for Seq
Apache License 2.0
13 stars 3 forks source link

[seq] Circular structure found #17

Closed Dru-Go closed 10 months ago

Dru-Go commented 10 months ago

The Error looks like the following

{"@t":"2023-10-17T18:53:34.2890000Z","@mt":"[seq] Circular structure found","@m":"[seq] Circular structure found","@i":"f91a6406","@l":"Error"}

image

My Logger setup is the following

import { createLogger, format, transports } from 'winston'
import { TransformableInfo } from 'logform'
import { SeqTransport } from '@datalust/winston-seq'

// Define log format
const customFormat = format.printf((info: TransformableInfo) => {
    const { timestamp, level, message, stack } = info
    return `${timestamp} [${level}]: ${message} ${stack || ''}`
})

// Define transports
const commonTransport = new transports.File({ filename: 'logs/common.log' })
const errorTransport = new transports.File({
    filename: 'logs/error.log',
    level: 'error'
})

// Define log transports
const transportsArray = [
    new transports.Console(),
    new SeqTransport({
        serverUrl: "http://localhost:5341",
        onError: (e => { console.error(e) }),
        handleExceptions: true,
        handleRejections: true,
      }),
    commonTransport,
    errorTransport
]

// Create logger instance
const logger = createLogger({
    level: 'info',
    defaultMeta: { application: 'Noah Server' },
    format: format.combine(
        format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
        format.errors({ stack: true }),
        format.splat(),
        format.json(),
        customFormat
    ),
    transports: transportsArray
})

export default logger
liammclennan commented 10 months ago

This message refers to the data being logged. You can't log an object that refers to an object that refers back to the first object because it can't be serialized.

Dru-Go commented 10 months ago

Thank you

liammclennan commented 10 months ago

You're welcome.