HAPI FHIR logging configuration for teams running a self-hosted server
Logging is a go-live decision, not a clean-up task. A HAPI FHIR JPA server running in your own infrastructure produces two kinds of output that teams need for different reasons. Application logs come from the server code and its dependencies through SLF4J, with Logback as the logging implementation typically configured in the deployment. Request logs come from the LoggingInterceptor, which records details about each incoming FHIR call. Troubleshooting, audit and security monitoring all draw on these streams, and the configuration you choose determines what is captured, where it goes and who can read it. Plan the logging design before go-live, because changing log destinations, formats and retention after patient traffic has started means reviewing months of output that may already contain data you did not intend to keep.
Start with an inventory of what your deployment will emit. Confirm in the documentation for your running version which fields the LoggingInterceptor records by default, since request logs can include resource identifiers, search parameters and request bodies depending on how the interceptor is configured. Check the Logback configuration shipped with the starter or WAR you deploy, the log levels set for the HAPI and Hibernate packages, and whether your application server or container adds its own access logs. Each of these is a separate source with its own file path or stdout stream. Decide which logger names need to be elevated during an incident and which should stay at a quiet level in production, and document the change procedure so an on-call engineer does not have to edit XML under pressure.
Treat patient data as a design constraint from the start. FHIR request URLs often carry patient identifiers and search values, so request logs can contain personal health information even when no resource body is logged. Work with your privacy and security teams to decide which fields are masked or omitted, how identifiers are hashed or truncated where correlation is needed, and who may read raw logs. HAPI FHIR does not provide a single security layer, so confirm with your compliance owners whether the audit trail you need is covered by the BALP audit logging building block or must be built separately. Structured output in JSON, which Logback can produce through an encoder, makes it easier to ship logs to a central collector with the same redaction rules applied everywhere.
Which logging layer answers which question
Application errors and startup problems are answered by the standard Java logging stack. HAPI FHIR logs through SLF4J, and the JPA server starter is typically configured with Logback. Logback appenders decide what is written, at which level, and where it goes. Startup messages cover database connection setup, schema validation, Spring context initialization and configuration errors, which are the first things to check after a failed deployment.
- Logger levels: Set
ca.uhn.fhirand the database driver packages toINFOin normal operation, and raise specific packages toDEBUGonly during an investigation. - Console appender: In containers, write to standard output so the platform log collector picks up startup and stack traces.
- Rolling file appender: On a single virtual machine or WAR deployment, use a file appender with size or time rotation so disk use stays bounded.
- Stack traces: Keep exception stack traces at
ERRORlevel so failed requests and failed jobs remain diagnosable. - Typical destination: Container logs flow to a cluster log agent, then to a central store your operations team already runs.
Before go-live, confirm the exact Logback configuration file your chosen deployment method loads, and test that a deliberate startup error appears in the central store.
Per-request history answers the question of what a client asked for, how long the server took and what it returned. In HAPI FHIR this is handled by the LoggingInterceptor, a server interceptor that writes a line for each request through the logging framework. It is separate from Logback's error handling: the interceptor decides what a request record contains, and Logback decides where that record is sent. Request logs are the most useful input for latency and error analysis, but they are also the most likely place for patient data to leak.
- Interceptor registration: Register the LoggingInterceptor on the server and choose a log format template that includes the operation, resource type, status and duration.
- Request identifiers: Include a request or correlation identifier so a request can be followed from the gateway to the database.
- Omit payloads: Do not log request or response bodies in production, because they carry clinical content.
- Query parameters: Search parameters can contain identifiers and names, so review which parameters the template prints.
- Typical destination: A dedicated logger or file that feeds a log search tool, with retention set by operations policy rather than by default.
Confirm the template fields against the HAPI FHIR version you deploy, since field names and defaults can change between releases.
Security and audit events answer who accessed which data, whether access was allowed, and whether configuration or identity settings changed. HAPI FHIR does not provide one complete security layer. It offers building blocks: authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS support and BALP audit logging. Audit records from these components are a different class of evidence from request logs and should be kept in a separate, access-restricted stream.
- BALP audit logging: The Basic Audit Log Pattern produces structured audit records of access to resources, which suits review by a privacy or security team.
- Authorization decisions: Log allowed and denied decisions from the AuthorizationInterceptor, including the identity and the operation, but not the clinical content.
- Authentication events: Record failed sign-ins and token problems from the identity provider and the authentication interceptor.
- Admin and configuration changes: Capture changes to partitions, search parameters and server settings, since these affect data exposure.
- Separate destination: Send audit records to a store with its own retention, integrity protection and read access, distinct from the operations log stream.
Confirm with your security and compliance team which events they must retain, for how long, and who may read them, before you choose the sink.
Structured logs make the three layers searchable together. Plain text lines are readable by people but hard to filter by field, so central collection tools work better with JSON or key-value output. Structured output also lets you route each layer to its own index or stream without parsing free text. The format choice depends on the logging library configuration you run and on the collector your organization uses.
- Encoder choice: Configure a JSON or structured encoder in Logback for the operations stream, and keep the layout consistent across environments.
- Logger name field: Keep the logger name in each record so application errors, request logs and audit records can be filtered apart.
- Consistent fields: Use the same names for timestamp, level, service, environment and request identifier across all three streams.
- Routing: Send the audit logger to its own appender and destination, so it is not mixed with high-volume request logs.
- Testing: Verify that the collector parses each stream and that a sample of each record type appears with the expected fields.
Check the encoder library version against your Logback version and your collector's supported formats before rollout.
Logging options and when each fits
This table compares the main logging choices for a HAPI FHIR server: appender type, encoder format, LoggingInterceptor detail and package-level levels. Read each row for its effect on log volume, troubleshooting value and PHI exposure, then confirm the named settings against the HAPI FHIR version you deploy. The main takeaway is that more request detail helps investigations but raises the chance that patient data reaches log storage.
| Option | Trade-off | When it fits |
|---|---|---|
| Logback console appender | Simple to run in containers. Output goes to the container runtime, so retention and rotation depend on the platform collecting it. | Containerized deployments where a log agent already collects stdout and forwards it centrally. |
| Logback file appender | Gives rotation and retention control on the host. Adds disk sizing work and a file shipper to move logs off the server. | Servers or WAR deployments on Tomcat, Jetty or Wildfly where logs must stay on local disk for a period. |
| Plain text encoder | Easy to read during an incident. Fields are hard to filter reliably in a central platform without parsing rules. | Small installations and early troubleshooting, with parsing rules tested before any central collection. |
| JSON encoder | Fields such as level, logger and request ID are queryable in central tools. Needs a configuration review to confirm which fields are emitted. | Production sites that forward logs to a central platform and build alerts on fields. |
| LoggingInterceptor with request and response detail | Highest troubleshooting value. Can capture resource bodies or query strings that contain identifiers, names or dates of birth, so PHI exposure risk is high. | Short, approved debugging windows in non-production environments with synthetic data. |
| LoggingInterceptor with minimal fields | Records method, path, status and timing. Lower volume and lower PHI risk, but less detail for diagnosing a specific failed request. | Default production posture, paired with tracing or metrics for latency and error analysis. |
| Debug level for HAPI packages | Very high volume and may echo request content. Useful for a bounded investigation only. | Temporary troubleshooting of a named package, reverted after the incident. |
| Info or warn level per package | Lower volume with fewer diagnostic details. Lowest PHI exposure when application code avoids logging payloads. | Steady-state production, with specific packages raised for a limited time. |
How PHI gets into logs and how to keep it out
The most common way protected health information reaches a log is through the request itself. A FHIR search such as Patient?identifier= or Patient?name= places patient identifiers and names directly in the URL and query string, and most servers, proxies and ingress controllers record those by default. Treat the request line as data that may contain PHI. Before go-live, capture a sample of real request lines from your access logs and confirm which query parameters carry identifiers, then decide whether the URL is logged in full, truncated or reduced to the resource type and operation. Ask your ingress or reverse proxy vendor how to configure the access log format, because the HAPI FHIR server cannot control what the layer in front of it writes.
The second and third leak paths sit inside the server. Body logging is useful during integration testing, but at debug level the request and response payloads of a Bundle or Patient resource can be written in full, and that setting is easy to leave on after a troubleshooting session. Exception messages are a quieter risk: validation and parsing errors often echo the offending element value, so a failed write can put a patient's data into a stack trace. Set body logging to off in production by default, verify the effective level of each ca.uhn.fhir and ca.uhn.fhir.rest logger in your Logback configuration, and review how your LoggingInterceptor settings handle request and response detail. Test error paths on purpose with synthetic records to see what ends up in the logs.
The controls to design are straightforward to describe and take more work to build. Use an allow-list of fields that the application may log, rather than trying to remove known sensitive values from a deny-list that will always lag new data elements. Scrub or hash identifiers before logs leave the server, and do it in the shipping pipeline so that a misconfigured service cannot bypass it. Restrict who can read the central log store, audit those reads, and set retention to what your operations and compliance teams have agreed. Confirm with your privacy and compliance owners which fields count as identifiers in your jurisdiction, since that list determines the allow-list. Enabling these controls does not by itself satisfy any regulatory requirement, so have them reviewed against your own obligations.
How to configure logging on a HAPI FHIR server
This sequence takes a HAPI FHIR server from an undefined logging setup to one with a written PHI policy, a tuned Logback configuration, request logging through the LoggingInterceptor, structured output for central collection, and verified rotation and retention.
Set the log policy and PHI rules
Before touching any configuration, the security or compliance lead and the platform team agree in writing which events must be logged, which fields may appear in each log line, and which fields are prohibited. Prohibited fields usually include patient names, dates of birth, identifiers such as medical record numbers, free-text search values and request bodies. Record who reviews log changes and where logs may be stored. The step is done when the policy is signed off and the team can point to a specific rule for each field a log line will carry.
Configure Logback for the server
The platform engineer edits the Logback configuration file on the server, typically
logback.xmlor the equivalent file the deployment reads, and sets the root level, the level forca.uhn.fhirand the level for the JPA packages separately. Keep the default level at INFO in production, raise individual packages only while investigating, and direct output to a named file appender and to standard output for container log collection. Run the server once with the file loaded and confirm in startup output that Logback reports the intended configuration file. The step is done when the server starts cleanly and the expected appenders are active.Register and configure the LoggingInterceptor
The engineer registers the LoggingInterceptor on the server so that each request produces one log entry, and selects the message template so that it records the request verb, resource type, response status and timing, but not the request body or query parameter values that may hold identifiers. Confirm the exact property names and template placeholders against the HAPI FHIR version in use, since they can change between releases. The step is done when a test search produces a single log line with the expected fields and nothing from the policy's prohibited list.
Switch to structured output
The engineer changes the console appender to a JSON encoder so that each request and error becomes a machine-readable record with consistent keys, such as timestamp, level, logger, thread and message. This needs a Logback JSON encoder library added to the build, which the team should confirm against its chosen Java and HAPI FHIR versions. Verify that the collector used by the organization, whether that is a log shipper, Graylog, Loki or another platform, parses the fields without custom rules. The step is done when a sample line from the running server parses into named fields in the collector.
Test that sample requests expose no identifiers
The QA or security engineer sends a set of representative requests to a test environment, including a read by identifier, a search with a patient identifier, a create with a sample resource, and a request that triggers an error. They then search the collected logs for every value used in the requests and for the field names on the prohibited list. This is best done with synthetic data so no real patient information enters a test environment. Any match is treated as a defect, the configuration is corrected and the test is repeated. The step is done when the search returns no matches for the test values and the results are recorded as evidence.
Confirm rotation and retention
The platform engineer confirms that the file appender rotates by the size or time settings chosen in the policy and that old files are removed after the retention period the organization has set. Check the central collection side separately, since the log platform often applies its own retention and access controls. Ask the platform owner to confirm the retention settings in writing so they match the policy and any obligations the organization must meet. The step is done when a forced rotation produces the expected files, old files are removed as configured, and the central store's retention matches the signed policy.
How log events flow from the HAPI FHIR server to central collection
The path starts with a client request arriving at the reverse proxy, which forwards it to the HAPI FHIR JPA server. The LoggingInterceptor and application code write events through SLF4J into Logback, where appenders hand them to a scrubbing point before anything leaves the server. Only scrubbed, structured events cross the trust boundary into the central log store. Check that request paths, query strings and bodies are filtered before the boundary, not after.
Log events leave the server only after the scrubbing filter, across the trust boundary.
Security and operational considerations for HAPI FHIR logs
HAPI FHIR does not provide a single security layer, so the controls around its logs are the operator's to design and run. The cards below cover the decisions that determine whether request logs stay useful for investigations without becoming a second copy of patient data.
Access to log stores
Request logs can reveal who searched for which patient, when, and from where, even when the payload is excluded. Limit read access to the log platform to named groups in your identity provider, separate operators who debug the server from staff who review audit events, and record who queried the logs. Confirm that the log platform's own administrator accounts are covered by the same review as the FHIR server's admin accounts.
Retention and deletion
Set one retention period for request logs and a separate, usually longer, period for security and audit events, and document both with the reason for each. Confirm that deletion runs on the log store itself, including rotated files and forwarded copies in the central platform. Check that backups of log stores follow the same deletion schedule, because an old backup can keep logs you have already deleted.
Integrity of audit records
Audit records are only useful if an administrator cannot quietly edit or remove them. Write security events to a store where the FHIR server's runtime account can append but not delete, and forward copies to a second system that the server cannot reach. Check that timestamps come from a synchronized clock on every node, so events from a Kubernetes cluster can be ordered during an investigation.
Separation of security and debug logs
Debug output from Logback can include request detail, stack traces and query text that a debugging engineer needs but an auditor should not read by default. Route security and access events to their own appender and destination, and keep debug loggers at a higher level in production. Confirm that turning on debug for one package does not expose patient-related content in the default log stream.
Log forwarding encryption
Forwarding logs from pods or servers to a central collector sends the same sensitive metadata across your network. Use TLS between each shipper and the collector, verify the collector certificate, and restrict which hosts may send logs to it. Confirm that agents do not fall back to plain text when a certificate expires, and that certificate rotation is in the operations runbook.
Alerting on logging failures
A server that keeps running while its logs stop flowing produces no evidence of misuse, which is the failure an attacker or a misconfiguration is most likely to cause. Alert when a forwarder stops shipping, when the log volume for the FHIR server drops to near zero, when disk space for local logs runs low, and when the audit appender reports write errors. Test each alert once by stopping the forwarder in a non-production environment.
Questions teams ask before configuring HAPI FHIR logging
How much effort does HAPI FHIR logging setup take?
Effort depends less on the Logback file itself and more on the decisions around it. The configuration work is small compared with agreeing what may be logged, which fields the central log platform needs, and how request logs are correlated with application and database logs. Teams with a clear log policy and a stable log platform move faster. Teams that must still decide whether request bodies, search parameters or patient identifiers can appear in logs will spend most of their time in review. Ask any partner to split its quote into policy and PHI review, configuration, central collection, and validation so you can see where the effort sits.
Can our in-house team configure HAPI FHIR logging without a partner?
Often yes, if the team already runs Java services and has someone who understands SLF4J and Logback. The HAPI FHIR server uses SLF4J, so the logging backend can be changed without touching application code, and the LoggingInterceptor can be enabled through configuration. The harder parts are the ones outside the server: confirming that no PHI reaches log sinks, testing that structured fields parse in your collector, and proving that retention and access controls match your policy. If your team lacks someone to own those checks, a partner can cover the gap, but the decisions still belong to you.
What does the logging work need from our team?
Three inputs matter most. First, a named log policy owner who can decide which request data may be logged, retained and accessed. Second, access to the environment where the HAPI FHIR server runs, including the deployment manifests, container or application server settings, and the central log platform. Third, a PHI review with your privacy or compliance lead, covering sample log output from non-production traffic. Without the policy owner, the team cannot close design questions, and without the PHI review, any log configuration remains unvalidated for regulated data.
How long does validating HAPI FHIR logging take?
Validation time depends on how many log sources, environments and sinks you have, and on how many review rounds your privacy team needs. A reasonable plan includes running the configuration against realistic non-production traffic, reviewing sample log lines for identifiers, confirming that structured fields arrive intact in the central platform, and checking that alerts and searches still work after a restart or rollout. Ask your partner to state the validation steps in the written scope and the number of review cycles they assume, so that schedule risk is visible before work starts.
What recurs after logging goes live?
Logging is not finished at go-live. Recurring work includes reviewing log output after releases, since new endpoints, search parameters or error messages can introduce new data in logs. It also includes rotating and retaining logs according to policy, reviewing access to the central platform, and checking that log volume and cost stay within what the platform team expects. Upgrades of HAPI FHIR or the logging libraries can change log formats, so each upgrade should include a short log review. Ask whether the partner offers this as a retainer or whether it returns to your team.
How does a partner scope HAPI FHIR logging work?
A partner should start with a short discovery that confirms the HAPI FHIR version, deployment method, database, central log platform and the data your server handles. From there, the written scope should list the logging backend and configuration changes, the LoggingInterceptor settings, the structured log format, the PHI review method, the validation steps and the handover material. DeployOpen works fixed-scope, so deliverables and timelines are agreed in writing before work starts, and a quote follows from that scope. Compare quotes by what each one includes, not by headline effort.
Which HAPI FHIR version and Java runtime should we confirm before scoping?
Confirm the exact HAPI FHIR version you run, because logging behavior and library dependencies can change between releases. HAPI FHIR 8.2.0 requires JDK 17, so check your runtime before planning any upgrade alongside logging changes. The current release listed in the project's GitHub releases page is v8.8.2, released on 25 September 2026. Compare your version against the versions documentation before choosing the logging setup, and confirm that your application server and container base image support the Java version you run.
How to test that no PHI reaches logs before go-live
Test for leaked PHI with marker data before any environment with real patients is connected. The approach is to send synthetic FHIR requests that carry unique marker values in the fields most likely to leak, then search everything the server writes for those markers. Build the markers into the test data itself: a fake patient name such as a string like ZZTEST-NAME-0417, a made-up identifier value, a birth date and a phone number in a recognizable pattern. Send them through the paths that matter: a create with a POST body, a search with the identifier in the query string, a PUT that updates a field, a failed validation request, and a request that returns an OperationOutcome with an error. Then search the output of each appender (console, rolling files, any separate audit or access log) and the stream arriving at your central collector for each marker. Any hit is a finding, and the marker shows you exactly which layer wrote it.
Repeat this test after every change that touches logging: a new Logback appender, a change to the level for ca.uhn.fhir or the request logging interceptor, a new collector pipeline, or a HAPI FHIR or dependency upgrade. Check the collector side too, including any parsing or enrichment step that copies fields into indexed labels, because a field that is safe in a file can become searchable in a shared index. Use only synthetic data for these runs, and keep the marker list and results in your own change records. Record what you tested, the configuration version, the date and who reviewed the output. Treat the result as evidence for your own security and privacy review, not as an audit outcome. An independent assessor will decide what evidence is sufficient for your obligations, and the test does not replace the controls you need to document around the server.
How DeployOpen scopes and delivers HAPI FHIR logging
A logging engagement starts with a written scope that fixes the log policy, the configuration changes, the PHI leak tests and the handover material. Each card below is one step in that scope, and each one has a clear output the client can review before the work is accepted.
Written log policy first
Before any configuration changes, the scope records which events are logged, at what level, which request fields are allowed in logs, and how long each log stream is kept. The policy names the owner of each decision, usually the security or privacy lead, so that later changes to logging go through the same approval path. Confirm with your privacy office which identifiers may appear in logs at all, because that answer drives every later setting.
Logback and SLF4J configuration
The configuration sets log levels per package in the Logback file that the JPA server starter loads, and routes HAPI and Spring output to the destinations the policy names. It also separates application logs from request logs so that each can have its own level, rotation and retention. Ask for the exact configuration files and a note on which Java logging setup your chosen deployment method uses.
LoggingInterceptor and request log content
The LoggingInterceptor controls which request details reach the log, including the URL, the search parameters and the response status. DeployOpen tunes it so that it records enough to investigate errors and slow requests while leaving out resource bodies and identifier values. Check each enabled field against the policy, because search parameters often carry patient identifiers.
Structured output for central collection
Logs are written in a structured format with stable field names so that a central collector can parse, index and filter them without custom rules. The scope covers the output format, the fields added to each entry such as request ID and server instance, and the agent or shipper that forwards them. Confirm which collector your organization already runs, since that choice decides the format.
PHI leak testing
DeployOpen sends test requests that contain synthetic patient data and then searches every log sink for those values, including error paths, bulk operations and failed authentication attempts. Any leaked value becomes a finding with the setting that caused it and a retest after the fix. The test uses synthetic data only, so no real patient record is needed during the engagement.
Handover and optional retainer
The handover package contains the approved policy, the configuration files, the leak test results and a short runbook for changing log levels. Logging changes after a HAPI FHIR upgrade or a new interceptor are a common source of regressions, so an optional retainer can cover upgrade checks and periodic leak testing. Ask for the retainer terms in writing, including the review cadence and what happens between reviews.
HAPI FHIR security docs
