I can't figure how to use the logging module Winston in typescript. I have an error when I try to set the logger level, and another one when I try to log an error:
import * as logger from "winston";
logger.level = 'debug';
// [ts] Cannot assign to 'level' because it is a constant or a read-only property.
logger.error(new Error('test'));
// [ts] Argument of type 'Error' is not assignable to parameter of type 'string'.
I have added both winston
and @types/winston
to my project.
Edit: to complete Joshua answer, it seem that by default winston logs to... nowhere. You have to add a transport to make it work:
import * as logger from "winston";
logger.configure({
level: 'debug',
transports: [
new logger.transports.Console({
colorize: true
})
]
});