Keycloak logging configuration and log shipping: what operations teams need from it
Logging configuration decides whether a running Keycloak can be monitored, investigated and retained by your security operations or platform team. It covers the output format, the log categories and their levels, HTTP access logs, and how the resulting records reach a log store such as Loki, OpenSearch or a SIEM. Teams need this work as soon as Keycloak handles production sign-ins, because an incident review or audit request will ask what was recorded, for how long, and where it now lives.
Default console output is rarely enough for either pipeline. A shipper or SIEM parses fields reliably only when the format is consistent, so teams should decide early whether they want structured JSON or an Elastic Common Schema style layout, and then test that the fields their detection rules need are present. Categories matter as well. When a login fails because of an LDAP bind, an identity broker callback or a token problem, the answer usually sits in a specific category, and that category may need a more verbose level than the rest of the server. Changing levels in production should be a planned, reversible step, not a permanent noise increase on every node.
Before building the pipeline, confirm the exact logging options for your Keycloak version in the server configuration documentation, and test them on a non-production node. Confirm which events you need to keep, how long your retention policy requires, and whether the log store's access controls match the sensitivity of usernames and client identifiers. Loki, for example, has no built-in authentication layer and needs an authenticating proxy in front of it, so the shipping design has to account for that from the start.
Which log output fits your pipeline
Plain text is usually the first output teams see when they run Keycloak in a container or on a virtual machine. It reads well in a terminal during an incident on one node, but a downstream system has to infer where each field starts and ends, so every shipping pipeline needs parsing rules.
- Human reading: Lines are quick to scan when you are tailing a single node during an incident.
- Parsing rules: Grok or regular expression rules must match each message layout, and they can break when message wording changes after an upgrade.
- Multi-line entries: Stack traces can span several lines that a shipper may split into separate events. Confirm how your shipper groups them.
- Field consistency: Confirm in the Keycloak logging guide which context fields, such as realm, client or user, appear in each line and whether they appear the same way every time.
Before you choose plain text for a Loki, OpenSearch or SIEM pipeline, check whether your team will maintain parsing rules after each Keycloak upgrade and whether your shipper can join multi-line events reliably.
JSON output writes each log event as a structured object, so a parser can read named keys instead of guessing positions in a line. It is usually the simplest path for Loki, OpenSearch and most SIEM platforms, though the exact keys and nesting depend on how Keycloak's logging configuration is set.
- Named fields: Consumers can filter on keys such as level, logger or message without custom extraction rules.
- Stable parsing: Structured events are less sensitive to wording changes in messages than plain text.
- Shipper support: Loki accepts logs from Grafana Alloy, Fluent Bit and Fluentd, and OpenSearch pipelines can ingest JSON documents. Confirm the exact ingest path your platform team has approved.
- Key naming: Confirm the key names Keycloak emits in the logging guide and whether they match the labels or fields your dashboards and detection rules already use.
Before you commit, test one sample of each event type, including login failures and LDAP errors, and confirm that every field your queries depend on is present in every event.
ECS refers to the Elastic Common Schema, a shared field naming scheme that many security tools understand. An ECS-style output aims to use those standard field names so that SIEM content, dashboards and detection rules written for other sources can read Keycloak events with less mapping. Whether Keycloak offers this output, and how closely its field names match, is something to confirm rather than assume.
- Shared field names: Standard names such as user, source address and event outcome can reuse existing SIEM parsers and dashboards.
- Mapping reduction: Fewer custom mappings means fewer places where a field can silently stop matching after an upgrade.
- Schema gaps: Keycloak-specific details such as realm or client identifiers may not have a standard field. Confirm how they are named.
- Consumer check: Ask your SIEM team which schema version their parsers expect and test a sample event against it.
For OpenSearch or Loki, an ECS-style layout is useful only if your team will keep the field names consistent across sources. Check the Keycloak logging guide for the exact schema it claims to follow before you write any mapping.
Syslog is the standard route when an existing collector, network appliance or security tool already receives events over the protocol. It fits organizations whose operations or security teams have standard syslog forwarding, but it adds transport decisions that matter for a identity provider, where losing login events can hide an attack.
- Existing collectors: Syslog works with collectors that many security teams already run, which can avoid a new agent on Keycloak hosts.
- Transport and reliability: Confirm which transport the Keycloak logging guide supports, and whether messages are delivered over the network without acknowledgment.
- Message size and format: Long JSON or multi-line messages can be truncated or reformatted by some collectors. Test with realistic login and error events.
- Encryption: Confirm whether the transport can be encrypted end to end and how your collector authenticates senders.
Before you rely on syslog for authentication events, verify that a test login failure reaches the collector intact, and confirm with your security team how dropped messages would be detected.
Logging options and when each fits
This table compares the Keycloak logging settings teams weigh before shipping logs, with the situations each suits and the cost in volume or sensitive data. Read each row as a decision: choose the output format your log platform parses, raise levels only for the category you are debugging, and turn off debug output before it reaches shared storage.
| Setting or option | When it fits | Trade-off to weigh |
|---|---|---|
| Plain console text output | Local troubleshooting, or a single-host lab where a person reads the console directly | Hard to parse reliably in a log platform, so field extraction breaks when messages change |
| JSON or ECS-style structured output | Shipping to Loki, OpenSearch or a SIEM where queries filter on fields such as level and logger name | Confirm the exact format name and field mapping for your version in the current logging docs before building parsers |
| Root log level (INFO or WARN) | Production default for the whole server, keeping steady-state volume predictable | Raising the root level to DEBUG across all categories can produce large volume quickly and may write request details to disk |
| Per-category level (for example LDAP federation or identity brokering) | Diagnosing one integration, such as a failing directory sync or an upstream OIDC or SAML broker, without flooding other logs | Lower the level again after the investigation, and confirm the category names in the current docs for your version |
| HTTP access logging | Auditing requests, correlating a slow login with a proxy or client IP, or supporting incident timelines | Adds volume on busy realms, and access lines can expose client addresses and paths that your privacy policy governs |
| Log handlers (console, file, syslog) | Console for containers, file where a host agent tails the file, syslog where an existing collector accepts it | Each handler has its own format and rotation behavior, so confirm which handlers are enabled and how they are configured per version |
| File rotation and retention on the host | Non-container installs where logs stay on disk until a shipper reads them | Without rotation, disk fills and the server can fail; confirm rotation settings against the current docs |
| Debug output in shared environments | Short, time-boxed investigations on a test or staging realm | Debug lines may include tokens, usernames or LDAP query details, so keep debug off in production and restrict who can read it |
How to set up Keycloak logging and log shipping
This sequence takes Keycloak from a chosen log consumer to verified, parsed events in production, with a check at each step so the operations team can trust what arrives in Loki, OpenSearch or the SIEM.
Decide the log consumer and retention needs
Before changing any Keycloak setting, the platform owner and the security or operations lead agree which system receives the logs (Loki, OpenSearch, or a SIEM), who queries them, and how long events must be kept. Loki retention is disabled by default, so logs are kept indefinitely until retention is configured, and this decision also determines the object storage or index sizing. Done when the consumer, owners and retention requirement are written down and the destination accepts a test record from any HTTP or syslog client.
Set output format and log levels in a test realm
In a non-production environment, the Keycloak administrator sets the console log format to JSON or ECS, which gives the collector fields it can parse without custom regular expressions, and chooses the handlers that write to the console or to a file. Per-category levels are raised only for the categories under investigation, such as the LDAP federation or identity brokering packages, so debug output does not flood the pipeline. Confirm the exact configuration keys against the Keycloak server configuration reference for the version in use. Done when the Keycloak startup log shows the expected format and a single test login produces a readable entry.
Enable HTTP access logs where required
If the security or audit team needs request-level records, the administrator enables HTTP access logging on the Keycloak server and confirms which fields it writes, such as method, path, status and client address. Access logs add volume, so the team agrees which paths are captured and whether the reverse proxy in front of Keycloak already records the same requests. Check the output for the proxy header the load balancer forwards, because without it the client address in the log may be the proxy address. Done when a test request appears in the access log with a correct client address and status code.
Route output through a collector
The platform engineer deploys one collector on each Keycloak host or pod, choosing Grafana Alloy for Loki, Fluent Bit for OpenSearch or a syslog forwarder where the SIEM requires syslog. The collector reads the container or file output, attaches stable labels such as the environment and the Keycloak instance name, and sends the records to the destination with the tenant or index settings that destination needs. Loki with authentication enabled also needs the X-Scope-OrgID header set on each request. Done when the collector reports successful sends and the test events arrive in the destination within the time the team considers acceptable.
Confirm parsed fields in the destination
In Loki or OpenSearch, the operations engineer runs a query for the test login and checks that the fields Keycloak emits, such as the event type, realm, user identifier and client identifier, are parsed as separate fields and not as one message string. The team also confirms that the log levels and timestamps are correct and that the time zone matches the other systems in the environment. Missing fields usually mean the format setting or the collector parser does not match, so the engineer fixes the pipeline before moving on. Done when a saved query returns the test login with each expected field populated.
Test alerts and access to the logs
Before production, the team triggers a controlled failed login and confirms the event appears, is searchable by the expected people, and triggers any alert rule built on it. Access to the log store is restricted to the roles that need it, and the team verifies that Loki sits behind an authenticating reverse proxy, since Loki has no built-in authentication layer, and that OpenSearch access is controlled through its Security plugin. Done when the alert fires once, the unauthorized test user is refused, and the authorized reviewer can query the events.
Roll out to production and review volume
The team applies the verified configuration to production in a planned change window, keeping debug levels off unless an incident requires them. After rollout, the operator watches log volume, collector errors and storage growth for the first few days and confirms that retention runs as configured. Changes to levels and access logs are recorded in the change system so later troubleshooting starts from a known state. Done when production events arrive from every Keycloak instance, the volume matches the sizing estimate, and the runbook names the owner for each setting.
How Keycloak logs reach Loki, OpenSearch or a SIEM
The diagram starts with Keycloak nodes writing server logs and the reverse proxy writing HTTP access logs. A log collector on the trusted side reads both and forwards them to one of three destinations: Loki behind an authenticating proxy, OpenSearch with its Security plugin, or a SIEM. The trust boundary sits around log storage, because logs carry usernames, client IDs and IP addresses. Check that the proxy sits in front of Loki and that OpenSearch access is limited by roles before any sink receives production traffic.
Keycloak and proxy logs flow through one shipper to Loki, OpenSearch or a SIEM.
Choosing Loki, OpenSearch or a SIEM as the destination
The destination decides who can search Keycloak logs, how long they stay, and what they cost to keep, so choose it before you tune log levels. Loki stores compressed log chunks and a label index in object storage, which keeps storage economical for high volumes, but Loki has no built-in authentication layer. Its documentation requires an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it, so you must design that proxy, its SSO integration and the X-Scope-OrgID tenant mapping as part of the build. Confirm with your platform team which object store and deployment mode you will run, since the Loki documentation says simple scalable mode is being deprecated and will be removed with Loki 4.0.
OpenSearch is licensed under Apache License 2.0, and its Security plugin supplies role-based access control, field-level security, audit logs and TLS for node and client traffic, so access control lives in the same product as the data. The upgrade path depends on the release line you adopt. OpenSearch 3.9.0 was released on September 29, 2026, and each version stays under maintenance for a defined period, after which it receives no further patches. Before you commit, confirm which release line your security team has approved, how you will move indices forward when it reaches end of maintenance, and whether your team has the capacity to run a cluster that stores audit data.
A SIEM is shaped by what already exists: detection rules, correlation content, case workflows and a retention contract the compliance team has signed. If your SIEM already has Keycloak parsers and alerts for failed logins, admin changes and brute-force patterns, shipping to it avoids building a second detection layer. Ask the SIEM owner which Keycloak event formats they ingest, what the licensing model charges for volume, and how long data must be kept. Retention is the decision most often missed. Loki retention is disabled by default, so logs persist indefinitely until retention_enabled is set. Set an explicit retention period in every destination, and write down who approves it.
Security and privacy risks in Keycloak logs
Keycloak logs are useful for operations and investigations, but they can also expose personal data, credentials and session details to anyone who can read them. The risks below connect to one another: a verbose setting or an unfiltered access log creates data that then needs protected storage, controlled retention and encrypted transport.
Debug output exposing personal data
Per-category debug levels for LDAP federation or identity brokering can record user attributes, search filters, distinguished names and upstream claims. Before enabling debug on any category in production, decide which fields are acceptable in logs and for how long debug stays on. Verify in a non-production realm what each category writes, then confirm that the production setting is reverted after troubleshooting. Ask whether your privacy team has approved the data categories in those messages.
Sensitive query strings in access logs
HTTP access logs record request paths, and some OAuth and OIDC flows place sensitive values in query strings, such as authorization parameters or redirect targets. Decide whether the access log format includes query strings at all, and test a login, a token request and a password reset to see what appears. Confirm that the reverse proxy in front of Keycloak applies the same filtering, because it may log requests before Keycloak sees them.
Access control on log storage
Log stores such as Loki or OpenSearch often become broadly readable because many teams query them. Define who may read Keycloak authentication logs, separate read access from administrative access to the store, and confirm that the query layer enforces it. Loki has no built-in authentication layer and needs an authenticating reverse proxy in front of it, so check that gap before onboarding users.
Loki authenticationTamper resistance and retention
Authentication logs are evidence during an incident, so they must be hard to alter and kept for a defined period. Loki retention is disabled by default, which means logs persist until you enable retention_enabled and set rules, so the retention period is a decision you must make explicitly. Confirm who can delete streams or change retention, and whether a copy leaves the system for audit review.
Loki retentionTransport encryption to the collector
Keycloak log lines travel from the server through a shipper such as Grafana Alloy, Fluent Bit or an OpenTelemetry Collector to the destination. Each hop can carry usernames, IP addresses and session identifiers, so encryption in transit should cover every leg, not only the public endpoint. Verify TLS on the shipper-to-store connection, check certificate validation in the agent configuration, and confirm that no hop falls back to plaintext when a certificate fails.
Questions teams ask before shipping Keycloak logs
What does Keycloak logging work cost and what drives the effort?
The cost is mostly the engineering time to set the log format, decide which categories stay at which levels, build the shipper configuration and wire the destination, then test that events arrive with the fields investigators need. Effort rises with the number of Keycloak nodes, how many log sources feed the pipeline (Keycloak, the reverse proxy, the database and any federation or brokering components), whether you need custom parsing, and how strict your retention and access rules are. Recurring costs come from log volume, storage and the platform itself. Ask any quote to list the fixed scope, the destinations covered, the parsing rules included and the handover items, and to separate one-time build work from ongoing support.
How long does a Keycloak log shipping setup usually take?
Duration depends mainly on the destination and how much parsing is needed. Shipping plain JSON lines to a platform your team already runs is the shortest path. Routing to Grafana Loki or OpenSearch adds work on storage, tenancy and access, and a SIEM adds field mapping and agreement with the security team on what must be forwarded. Custom parsing for multi-line events or per-realm fields adds more time. No duration is fixed here, so ask for a timeline in the written scope, with milestones for format decisions, pipeline testing and the handover of dashboards or queries.
What must our team provide before logging work starts?
Plan to provide access and decisions, not just time. The usual list includes:
- Access to the Keycloak test and production environments, including the way logs are collected from containers or hosts
- Access to the destination, such as a Loki tenant, an OpenSearch cluster or the SIEM ingestion endpoint, with an account allowed to create indexes, streams or parsing rules
- Written retention rules, including how long authentication and admin events must be kept
- Parsing requirements, such as the field names your SIEM expects or the ECS mapping your team uses
- Named owners for security review and sign-off on what personal data appears in logs
Missing items usually delay the schedule more than the technical work does.
Can our own team set up Keycloak logging without a partner?
Yes, if you have engineers who can run Keycloak, operate the chosen log platform and make the security decisions. Keycloak exposes logging options that can be set through configuration, and the destination products document their own agents and ingestion methods. The harder parts are usually the decisions: which categories to raise to debug temporarily, how to avoid logging secrets or personal data, how to keep one event format across Keycloak and the proxy, and how to test that alerts fire. A partner can be used for the full build, a review of an existing setup, or a fixed-scope handover. Confirm your internal skills against each step before deciding.
Which Keycloak log fields matter most for investigations?
For login investigations, the fields that matter are the timestamp with time zone, the log level and logger category, the realm, the client ID, the event type, the user identifier, the source IP address as seen by the proxy, the request or correlation identifier and the error reason. Admin actions need the acting administrator and the target object. Keep the same field names across Keycloak and the reverse proxy so one query can follow a request through both. Confirm with your security team which identifiers may be stored, and whether IP addresses and usernames are treated as personal data in your jurisdiction.
How does logging change when we upgrade Keycloak?
Upgrades can change log output, categories and sometimes event content, so the log pipeline should be part of the upgrade test plan. Check that parsing rules still match the new fields, that dashboards and alerts still receive data, and that the set of logger categories you raised for debugging still exists. Keycloak's upgrade notes for each release list changes that affect configuration, and the project's 26.8 notes cover login failures stored in the database and stricter email and token behavior that can show up in logs. Ask the quote to include a post-upgrade check of shipped events in the staging environment before production.
Should we ship Keycloak logs to Loki, OpenSearch or a SIEM?
Choose by what your team already operates and what the logs must support. Grafana Loki is a log store that indexes labels and keeps data in object storage, and it needs an authenticating reverse proxy in front because it has no built-in authentication layer. OpenSearch is an Apache 2.0 search and analytics platform with a security plugin that provides role-based access control and audit logs. A SIEM is usually the choice when the security operations team needs correlation and case handling. Many teams send the same JSON events to two places. Ask any proposal to explain the trade-offs for your retention, access and query needs before it commits to a destination.
How DeployOpen scopes and delivers Keycloak logging work
DeployOpen plans Keycloak logging as part of the running identity service, not as an afterthought. The work starts from the questions your operations and security teams need answered, then configures Keycloak's log output and shipping inside infrastructure you control, with the result documented and handed over in writing.
How we scope
- Agree in writing which log formats, categories, levels and destinations the engagement covers, such as JSON output, HTTP access logs and a named SIEM or log store.
- Inventory where Keycloak runs, which log platform already exists and who owns retention, access and alert routing for those logs.
- Confirm sensitive-data handling early, including which events may carry user identifiers and which fields must be excluded before shipping.
How we build
- Configure Keycloak logging with per-category levels for the areas you need, such as LDAP federation or identity brokering, and keep the defaults quiet.
- Set up the shipping path to your chosen destination, whether Loki, OpenSearch or a SIEM, and test that events arrive with the expected fields.
- Test log output against real login, failed login, admin and federation events in a non-production environment before any production change.
How we hand over
- Deliver written configuration with the Keycloak settings, shipper configuration and the field mapping your analysts will query.
- Document the log levels, retention assumptions and access controls so your team can change them without reworking the pipeline.
- Walk your operations and security staff through searches, dashboards and the troubleshooting steps the logs support.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer, which covers changes after a Keycloak or log platform upgrade.
- Ask any DeployOpen quote to separate one-time build work from recurring support, so you can compare it with your own team's effort.

