---
title: "Logging"
description: "Send a record of each request a WAF matched, or of every request, to Observability in the WAF's project."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Logging

A WAF can log requests to [Observability](/observability) in its own project. Its `logging` has a
`scope` and an `environment`:

| `scope` | Logs |
| --- | --- |
| `off` | Nothing (the default). `environment` is `null`. |
| `matched` | Each request a rule or managed rule set matched: blocked, logged, allowed by a rule, or over a rate limit. |
| `all` | Every request the WAF inspected, with its response status. |

```json
"logging": { "scope": "matched", "environment": "production" }
```

`environment` is the Obs environment the records go to, in the WAF's project. Creating or changing a
WAF whose logging is on needs `obs.logs.ingest` on the project; without it, the request is
`403 access_denied`.

Records are billed as Observability log ingest in the project. `all` logs every request, so it costs
more on a busy load balancer than `matched`.

## Records

Each record is a log with `service.name` `ezgh.waf`, in the dataset of the WAF's environment. Its body
is JSON:

| Field | |
| --- | --- |
| `time` | When the request arrived |
| `loadBalancerId`, `listenerId` | The load balancer and listener that took the request |
| `wafId`, `wafVersion` | The WAF and the version of it that inspected the request |
| `action` | `allow`, `block` or `log` |
| `terminatingRule` | The rule that blocked the request, or would have in log-only mode: its `ruleSet` (`custom` for your own rules) and `ruleId`, and a custom rule's `name`. `null` when none did, as for a request an `allow` rule let through (see `matchedRules`). |
| `matchedRules` | Every rule that matched, in the same form |
| `anomalyScore` | The request's Core rule set (OWASP CRS) anomaly score |
| `clientIp`, `country`, `asn` | The client IP, and its country (ISO 3166-1 alpha-2) and AS number when known |
| `method`, `host`, `path`, `query` | The request line and host |
| `userAgent` | The `User-Agent` header |
| `status` | The response status: `403` for a blocked request |
| `requestId` | The request's ID |

A record never includes the request body, cookie values, the `Authorization` header or other
credential headers.

## Search

```sh
ezgh obs search --environment production --service ezgh.waf --from 1h
```

See [Find blocked requests](/waf/guides/find-blocked-requests).

Country and ASN come from DB-IP data. This product includes IP data from
[DB-IP](https://db-ip.com), licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).

Source: https://docs.ezghcloud.com/waf/logging/index.mdx
