gremo/nest-winston

Unable to write to file with nest-winston

painkkiller opened this issue · 3 comments

I have the nestjs app, and I am trying to implement logging with your package. I've found that my app falls silently without any errors when I trying to write to file.
My logger file:

import * as winston from "winston";
import * as stackTrace from "stack-trace";
import { WinstonModule } from 'nest-winston';

const { combine, timestamp, printf } = winston.format;

const myFormat = printf(({ level, ...info }) =>
    JSON.stringify({
        log_level: level,
        ...info
    }).replace(/\\\\\"/g, '"')
);

export const logger = WinstonModule.createLogger({
    level: "debug",
    format: combine(timestamp(), myFormat),
    defaultMeta: {
        application: "backend",
        application_stack: "data-validation"
    },
    transports: [
        new winston.transports.Console({
            format: winston.format.simple(),
            silent: process.env.env !== "development",
            handleExceptions: true
        }),
         // this block produces silent fall nestjs app when uncommented
        /* process.env.log_file ? new winston.transports.File({
            filename: process.env.log_file,
            maxsize: 50 * 1024 * 1024,
            maxFiles: 2,
            handleExceptions: true
        }) : undefined */
    ]
});

main.ts inside bootstrap function

import { logger } from './lib/logger';

....

const app = await NestFactory.create(AppModule, {
    logger
  });

same problem

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been stalled for 7 days with no activity.