express-stormpath icon indicating copy to clipboard operation
express-stormpath copied to clipboard

Error in configuring Stormpath logger

Open mattilindell opened this issue 9 years ago • 3 comments

Hi,

Stormpath fails to use my (simplified) logging module:

logger.js: module.exports = require('winston');

app.js: var logger = require('./lib/utils/logger'); app.use(stormpath.init(app, { logger: logger, ....

I get the following error: TypeError: b.hasOwnProperty is not a function at extend (/foo/node_modules/stormpath-config/node_modules/cloneextend/index.js:53:9)

Thanks, Matti

mattilindell avatar Apr 06 '16 19:04 mattilindell

Hi Matti, you won't be able to pass the Winston module directly. You need to create a Winston logger instance, configure it, then pass it to our library. For example:

var myLogger = new winston.Logger({ /* your winston options */});

app.use(stormpath.init(app, {
  logger: myLogger
}));

From the docs: http://docs.stormpath.com/nodejs/express/latest/configuration.html#logging

robertjd avatar Apr 06 '16 23:04 robertjd

Hi, With this I get the same error. Should this work though?

logger.js:

module.exports = new winston.Logger({
    level: 'info',
    transports: [
      new (winston.transports.Console)()
    ]
  });

app.js:

var myLogger = require('./lib/utils/logger');
app.use(stormpath.init(app, {
  logger: myLogger
}));

Thanks, Matti

mattilindell avatar Apr 07 '16 05:04 mattilindell

same

devpascoe avatar Aug 02 '16 04:08 devpascoe