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

Example not working: Logging not serializing arguments #1699

Open
1 task
basickarl opened this issue Sep 3, 2019 · 2 comments
Open
1 task

Example not working: Logging not serializing arguments #1699

basickarl opened this issue Sep 3, 2019 · 2 comments

Comments

@basickarl
Copy link

Please tell us about your environment:

  • _winston version?_3.2.1
    • winston@2
    • [x ] winston@3
  • _node -v outputs:_v10.16.0
  • Operating System? (Windows, macOS, or Linux) Linux
  • Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart) TypeScript 3.4.5

What is the problem?

    const log = createLogger({
        level: logLevel,
        format: format.json(),
        defaultMeta: { service: 'user-service' },
        transports: [
            new transports.File({ filename: 'logs/error.log', level: 'error' }),
            new transports.File({ filename: 'logs/combined.log' })
        ]
    });
        log.add(
            new transports.Console({
                format: format.simple()
            })
        );

Console transport is not serializing the arguments.
Expecting all arguments

What do you expect to happen instead?

According to https://github.com/winstonjs/winston/blob/master/README.md#usage the above states: ${info.level}: ${info.message} JSON.stringify({ ...rest }) instead the following code log.debug('hello', { there: 1 }); results in the following: debug: hello [object Object] {"service":"user-service"}. My Object has not been serialized.

Other information

@fourpastmidnight
Copy link

fourpastmidnight commented Jun 11, 2021

Hmm, I believe the issue I filed, #1933, is related to this. It seems like whenever two or more transports are in use, the first transport listed gets the full info object, but the second transport only receives an info object with Winston "known" properties, i.e. level, message, timestamp, and the [Symbol(splat)] properties.

@fourpastmidnight
Copy link

There is a comment on #1430 which resolves the issue with info "losing data" between transports.

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

2 participants