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

need to exclude certain url paths #23

Open
bigriot opened this issue May 21, 2019 · 2 comments
Open

need to exclude certain url paths #23

bigriot opened this issue May 21, 2019 · 2 comments

Comments

@bigriot
Copy link

bigriot commented May 21, 2019

My server receives health check pings from a load balancer via '/ping'.

The health check happens every 30 seconds so meaningless logs will pile up rather quickly, especially if I've got multiple instances running at the same time.

I think hapi-pino has something like this with an ignorePaths option, and was wondering if we could get something similar for koa.

@alexdeia
Copy link

alexdeia commented Jun 3, 2020

Hi @bigriot !

You can try something like this

    app.use(async (ctx, next) => {
      if (ctx.url === '/ping') {
        await next();
      } else {
        await logger()(ctx, next);
      }
    });

@abeluck
Copy link

abeluck commented Oct 8, 2020

This method is not ideal.

If the ignored route uses a log function ctx.log.info, then it will cause an error.

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

3 participants