# Logging request's attributes in server log

**URL:** <https://softwaremill.community/t/logging-requests-attributes-in-server-log/76>\
**Category:** tapir\
**Created:** [January 4, 2023, 1:14pm UTC](https://softwaremill.community/t/logging-requests-attributes-in-server-log/76 "2023-01-04T13:14:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleksandr-vin](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/aleksandr-vin/32/64_2.png) [@aleksandr-vin](https://softwaremill.community/u/aleksandr-vin)\
**Post date:** [January 4, 2023, 1:14pm UTC](https://softwaremill.community/t/logging-requests-attributes-in-server-log/76/1 "2023-01-04T13:14:40Z")

</div>

We are running tapir with caliban, which acts very well together. But graphql is served on one path and that makes path logging useless for us, while there is a notion of _operation name_ in graphql, which we want to log instead. Plus we have a user id which is authenticated in request interceptor, which we put in request attributes. Now we want to log some request’s attrs in server logs, to get smth like this:

```auto
2022-12-23T09:10:09.097413674Z DEBUG [ZScheduler-0] s.t.s.http4s.Http4sDefaultServerLog - Request: POST /api/graphql, handled by: POST *, took: 14085ms; response: 200; operation name: weatherForecast; user: x123456

```

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [January 4, 2023, 1:59pm UTC](https://softwaremill.community/t/logging-requests-attributes-in-server-log/76/2 "2023-01-04T13:59:35Z")

</div>

I think it would be best to create a custom `GraphqlLoggingInterceptor` - similarly to the one which performs authentication.

In fact, this might be even slightly easier: providing a custom `ServerLog` implementation should do the trick. The methods receive the whole request as a parameter, so you should be able to get all that you need.

The operation names comes in a query parameter? If so, it shouldn’t be a problem to log this as well. You can then substitute the `ServerLog` implementation using the `CustomiseInterceptors.serverLog` method.
