- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
import winston from 'winston'
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
name: 'info-file',
filename: './logs/info.log',
level: 'info'
}),
new (winston.transports.File)({
name: 'error-file',
filename: './logs/error.log',
level: 'error'
}),
new (winston.transports.File)({
name: 'debug-file',
filename: './logs/debug.log',
level: 'debug'
})
]
});
export default logger
// using it like this
logger.error('could not write to file')
logger.info('gj. nice work')
logger.debug('start debugging')