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

Writing logs to a file instead of console #146

Closed
usersina opened this issue Jan 5, 2021 · 2 comments
Closed

Writing logs to a file instead of console #146

usersina opened this issue Jan 5, 2021 · 2 comments

Comments

@usersina
Copy link

usersina commented Jan 5, 2021

I have a small express application that writes logs to a file.

In morgan, I'm doing the following:

// ...
app.use(
  morgan('combined', {
    stream: fs.createWriteStream('./my_file.log', {
      flags: 'a',
    }),
  })
);

However, this won't work if I switch to cabin: (Still logs to console but no changes to file)

const Cabin = require('cabin');
const cabin= new Cabin({
    stream: fs.createWriteStream('./test.log', {
      flags: 'a',
    }),
  });
// ...
app.use(cabin.middleware);
@niftylettuce
Copy link
Contributor

You can use axe option to use morgan or pino (e.g. pino stream).

@niftylettuce
Copy link
Contributor

niftylettuce commented Jan 14, 2021

const cabin = new Cabin({
  axe: {
    logger: env === 'production' ? pino : morgan // whatever you want here (in place of `console`)
  }
});

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