Skip to content

Conversation

Joe-Edwards-GDS
Copy link
Contributor

@Joe-Edwards-GDS Joe-Edwards-GDS commented Oct 17, 2025

What

Updated log4j2 configuration to use JsonTemplateLayout

  • JsonTemplateLayout provides fine-grained control over which fields are emitted, and e.g. allows us to omit irrelevant data
  • The existing JsonLayout is 'considered deprecated'

See https://logging.apache.org/log4j/2.x/manual/json-template-layout.html for full documentation

Comparison

Existing log:

{
  "instant": {
    "epochSecond": 1760697868,
    "nanoOfSecond": 357164340
  },
  "thread": "JettyServerThreadPool-42",
  "level": "INFO",
  "loggerName": "uk.gov.di.authentication.frontendapi.services.StartService",
  "message": "Found UserStartInfo for Authenticated: false UpliftRequired: false IdentityRequired: false. CookieConsent: null. GATrackingId: null. IsBlockedForReauth: false",
  "endOfBatch": false,
  "loggerFqcn": "org.apache.logging.log4j.spi.AbstractLogger",
  "threadId": 42,
  "threadPriority": 5,
  "session-id": "3ixQF_KEweXmTmIHcSgecsx7VBg",
  "persistent-session-id": "ET46o9BABu_iMqo8Wr8ARzMdoeE--1755600903901",
  "client-session-id": "CMdfoFdhRZLHPf8rnHXzncvJ6eM",
  "govuk_signin_journey_id": "CMdfoFdhRZLHPf8rnHXzncvJ6eM",
  "client-id": "local-client-id"
}

New:

{
  "instant": {
    "epochSecond": 1760697141,
    "nanoOfSecond": 508495212
  },
  "level": "INFO",
  "loggerName": "uk.gov.di.authentication.frontendapi.services.StartService",
  "message": "Found UserStartInfo for Authenticated: false UpliftRequired: false IdentityRequired: false. CookieConsent: null. GATrackingId: null. IsBlockedForReauth: false",
  "session-id": "8ulo1PSYX3Mh8qeZ-HvsbC5QVEw",
  "persistent-session-id": "ET46o9BABu_iMqo8Wr8ARzMdoeE--1755600903901",
  "client-session-id": "5-arASqz61ZtLY7AasQ-akAHqNU",
  "govuk_signin_journey_id": "5-arASqz61ZtLY7AasQ-akAHqNU",
  "client-id": "local-client-id"
}

How to review

  1. Code Review
  2. [Optional] Deploy to dev env and check logs look suitable

I have already deployed to orch dev and checked some logs there (but not auth dev)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this is based on https://github.com/apache/logging-log4j2/blob/rel/2.25.2/log4j-layout-template-json/src/main/resources/JsonLayout.json which mimics the output of JsonLayout.

We don't have to keep this - some things to consider:

  • Changing the timestamp format to ISO-8601 for readability
  • Removing client-session-id (if it's always the same as govuk_journey_id)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want to double check we are definitely setting the journey id everywhere - I'm pretty sure we are, but the team mostly currently rely on client-session-id for querying logs so there's a small chance it's not been added somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - I'll probably leave it in for now, and let you tweak further as you like, hopefully it's fairly obvious how to update the config to do that!

(This specific file doesn't have it - because it's not logged in acct management API, but it should still be present in all the orch stuff)

@Joe-Edwards-GDS Joe-Edwards-GDS force-pushed the BAU/update-logging-config branch from 011f3cd to 892c67e Compare October 17, 2025 13:26
@Joe-Edwards-GDS Joe-Edwards-GDS marked this pull request as ready for review October 17, 2025 13:55
@Joe-Edwards-GDS Joe-Edwards-GDS requested review from a team as code owners October 17, 2025 13:55
Copy link

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

Successfully merging this pull request may close these issues.

2 participants