Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error objects are not logged #1426

Closed
1 of 2 tasks
soulchild opened this issue Aug 3, 2018 · 6 comments
Closed
1 of 2 tasks

Error objects are not logged #1426

soulchild opened this issue Aug 3, 2018 · 6 comments

Comments

@soulchild
Copy link

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • node -v outputs: v9.5.0
  • Operating System? macOS
  • Language? ES6/7

What is the problem?

The following code does not log the Error object, but just:

{"level":"error","message":{},"timestamp":"2018-08-03T13:38:21.376Z"}
const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  transports: [
    new winston.transports.Console({
      format: winston.format.combine(winston.format.timestamp(), winston.format.json())
    })
  ]
});

logger.log({ level: 'error', message: new Error("Yo, it's on fire") });

I experimented with custom formatters:

winston.format.printf(info => `${info.timestamp} [ ${info.level} ] ${info.message}`)

which logs the Error message, but there's still no stack trace.

What do you expect to happen instead?

Coming from Winston@2, I'd expect this to log the Error object including a stack trace.

@frenzymind
Copy link

I have the same problem. I use winston-mongodb, and in 'meta' property in database I see level and error message, but not error object.

@rduque1
Copy link

rduque1 commented Aug 10, 2018

+1

@xduseko
Copy link

xduseko commented Aug 13, 2018

Same problem here.

@heeju
Copy link

heeju commented Aug 14, 2018

Error object gives undefined

@hbakhtiyor
Copy link

still not fixed 😕

@DABH
Copy link
Contributor

DABH commented Sep 3, 2018

Valid concerns! There is a nice workaround by @SamuelMaddox17 / @indexzero in #1338 , but we should do something so this works more out-of-the-box. Let's track this issue in #1338 since it's the same thing. Thanks all!

@DABH DABH closed this as completed Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants