Skip to content

Instantly share code, notes, and snippets.

@uurtech
Created March 12, 2020 16:05
Show Gist options
  • Save uurtech/1158f9f3914c05869fb07e3fbe47863f to your computer and use it in GitHub Desktop.
Save uurtech/1158f9f3914c05869fb07e3fbe47863f to your computer and use it in GitHub Desktop.
Typescript Nodejs Logger script
import * as dotenv from 'dotenv';
import winston from 'winston'
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
new winston.transports.File({ filename: process.env.ERROR_LOGS, level: 'error' }),
new winston.transports.File({ filename: process.env.WARNING_LOGS, level: 'warning' }),
new winston.transports.File({ filename: process.env.INFO_LOGS, level: 'info' }),
]
});
export default logger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment