Closed stanislav-web closed 2 years ago
You should create a moleculer.config.js
and put the logger config into it:
https://moleculer.services/docs/0.13/logging.html#Winston
// moleculer.config.js
const winston = require("winston");
const { extend } = require("moleculer").Logger;
module.exports = {
logger: bindings => extend(winston.createLogger({
format: winston.format.combine(
winston.format.label({ label: bindings }),
winston.format.timestamp(),
winston.format.json(),
),
transports: [
new winston.transports.Console()
]
}))
};
@icebob its doesn't work I added winston.transports.File but logs files does not created. `transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: './error.log', level: 'debug' }),
new winston.transports.File({ filename: './combined.log' })
]`
As you can see console working properly as before with default logger configuration
LOG_LEVEL=info LOG_FORMATTER=default
Please try it again with Moleculer 0.14 and Moleculer-web 0.9
Hi, there! I need to implement winston logger for my web service but i dont have created any ServiceBroker . My services started directly from console launcher...
/node_modules/.bin/moleculer-runner --repl --hot --envfile .env.dev endpoints
So , my question is actual because i don't know how to implement winston logger instead of basic console. Can anyone help me ?