Winston not Logging to console in typescript

When you instantiate a new Logger instance you need to provide it a list of transports so it knows where to send the logs:

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)(),
    new (winston.transports.File)({ filename: 'somefile.log' })
  ]
});

Well,

thanks to the hint of @idbehold , I found that a plain and easy:

import * as winston from "winston";

winston.info('Now my debug messages are written to the console!');

works for the default logger..


This is the Typescript way to import Winston.

First, be sure you have installed the typing :
npm i -D @types/winston

Then, in your script.ts

import { Logger, transports } from 'winston';
var logger = new Logger({
  transports: [
    new transports.Console(),
    new transports.File ({ filename: 'somefile.log' })
  ]
});

In genral, you can import all constants and types without using winston.<...> before.