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

How to add custom field? #217

Open
vickyRathee opened this issue Apr 25, 2023 · 0 comments
Open

How to add custom field? #217

vickyRathee opened this issue Apr 25, 2023 · 0 comments

Comments

@vickyRathee
Copy link

I'd like to add custom field in logs collection, but it's not written in DB. Any suggestion?

const metaFormat = winston.format((info) => {
  return { ...info, app: 'test' };
});

const transports  = [
              new winston.transports.MongoDB({
                db: process.env.MONGODB_CONNECTION,
                options: {
                  useUnifiedTopology: true,
                },
                collection: 'logs',
                format: winston.format.combine(
                  metaFormat(),
                  winston.format.json(),
                ),
              }),
            ]
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

1 participant