Skip to content

Invalid transport, must be an object with a log method #12

@Fl4m3Ph03n1x

Description

@Fl4m3Ph03n1x

I have the following code snippet:

const winston = require("winston");
const logzioWinstonTransport = require("winston-logzio");

const winstonFactory = ({ API_TOKEN }) => {
    
    const loggerOptions = {
        token:  API_TOKEN,
        host:   "listener.logz.io",
        type:   "nodejs"
    };
    
    winston.add( logzioWinstonTransport, loggerOptions );

    return winston;
};

module.exports = winstonFactory;

Upon executing winstonFactory(), I get the following error:

Error: Invalid transport, must be an object with a log method.
at new LegacyTransportStream (/home/ubuntu/workspace/node_modules/winston-transport/legacy.js:17:11)
at DerivedLogger.add (/home/ubuntu/workspace/node_modules/winston/lib/winston/logger.js:277:7)
at Object.winston.(anonymous function) [as add] (/home/ubuntu/workspace/node_modules/winston/lib/winston.js:84:34)
at winstonFactory (/home/ubuntu/workspace/src/deps/winston.js:12:13)
at setupDeps (/home/ubuntu/workspace/src/deps/index.js:4:15)
at setupApp (/home/ubuntu/workspace/src/app.js:5:24)
at Object. (/home/ubuntu/workspace/server.js:2:13)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)

You can also reproduce the said error by dong this simple tutorial:

https://codeburst.io/setting-up-a-nodejs-monitoring-and-error-alert-system-in-a-jiffy-5241a4ef0561

Am I missing somehting or doing something wrong?
Why isn't it working ?


versions:

  "dependencies": {
    "winston": "^3.0.0-rc2",
    "winston-logzio": "^1.0.6"
  }

NODE: 9.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions