Use shared springutils logger in RACM - #126
Open
glemson wants to merge 3 commits into
Open
Conversation
RACM maintained its own logging infrastructure alongside the spring-utils logging beans that were already active via component scan, resulting in two Logger instances at runtime with only the RACM-local one actually used for RACM/JOBM/FileService messages. - Delete config/LoggingConfig.java; spring-utils LoggerConfig already reads the standard logging.* properties. - LogUtils: drop the singleton, setupLogger(), and the isLogInfoEnabled()/ isLogErrorEnabled() guards; resolve the spring-managed Logger bean via Log.getLogger(). SendMessage checks remoteEnabled/consoleEnabled/fileEnabled internally. - LoggingInitializer: reduce to a @component injecting logging.jobm.application via @value and setting it through a static setter. The default matches the previous DEFAULT_JOBM_APPLICATION_NAME, so no new Helm key is needed. - racm-application.yaml: remove the now-unbound org.sciserver.racm.logging block, add logging.rabbitmq.queuename, and match fileservice exactly. - FileServiceRepository: replace two System.out.printf calls with LOG.warn(). LogUtils.buildLog() and the LogBuilder fluent API are unchanged; all 11 callers required no modification. One production-visible change: emitted messages previously carried Host = "Kubernetes" from the deleted config. LoggerConfig does not set applicationHost, so Logger.setupMessage() now falls back to the pod hostname, matching fileservice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Covers the behavior the springutils logger migration changed: which application name and message type each LogUtils path puts on the message. LogUtils resolves its Logger through the static ApplicationContext held by Log, so the tests populate that static with a mock context instead of starting a Spring context. A bare Logger has no sink enabled, so SendMessage does no I/O and a Mockito spy captures the message that was built. - jobmLogUsesConfiguredJobmApplicationName / jobmErrorLogUsesConfigured- JobmApplicationName pin the configured JOBM name, which is what replaced LoggingConfig.getJobmApplicationNameForLogger(). - racmLogKeepsLoggerApplicationName, fileServiceLogKeepsLoggerApplicationName and racmErrorLogKeepsLoggerApplicationName pin that the Application name is not overridden outside the JOBM paths. - loggerFailureDoesNotPropagateToCaller pins that wrapSendingMessage swallows a SendMessage failure, so a logging problem cannot break a request. That test intentionally emits an ERROR line on the console. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
glemson
marked this pull request as ready for review
July 31, 2026 20:33
glemson
requested review from
amitschang and
Copilot
and removed request for
Copilot
July 31, 2026 20:34
amitschang
approved these changes
Aug 4, 2026
amitschang
left a comment
Contributor
There was a problem hiding this comment.
Change-wise it looks fine to me. The log functions that are rewired are somewhat redundant now with the per-request injected logs (before this change), but I think in exception cases they miss some information due to exceptions getting eaten in endpoints. Something to look to change in the future probably.
| logging.application: RACM | ||
| logging.rabbitmq.host: {{ include "sciserver.rabbitmq_host" . }} | ||
| logging.rabbitmq.exchange: {{ .Values.logging.rabbitmq.exchange }} | ||
| logging.rabbitmq.queuename: {{ .Values.logging.rabbitmq.queuename }} |
Contributor
There was a problem hiding this comment.
Skeptical that this is needed, as it should be consumer related. But also shouldn't harm anything being here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates RACM from its custom dual-logging setup to the shared
springutils:logging-interceptorpattern, eliminating a redundantLoggerinstance.Problem
RACM maintained its own parallel logging infrastructure alongside the spring-utils logging beans that were already active via component scan:
LoggingConfig.java— custom@ConfigurationPropertiesreadingorg.sciserver.racm.logging.*, duplicating whatLoggerConfig(spring-utils) already provides.LoggingInitializer.java— created a secondLoggerinstance insideLogUtils, separate from the spring-managed bean.LogUtils.java— static singleton holding its ownLogger, with manualenabledguards.The result was two
Loggerinstances at runtime, with only the RACM-local one actually used for RACM/JOBM/FileService log messages.Changes
Deleted
config/LoggingConfig.java— replaced by spring-utilsLoggerConfig, which reads the standardlogging.*properties.Refactored
LogUtils.java— removed the singletoninstance,setupLogger(), and theisLogInfoEnabled()/isLogErrorEnabled()guards. Now resolves the spring-managedLoggerbean viaLog.getLogger().LoggingInitializer.java— reduced to a@Componentthat injectslogging.jobm.applicationvia@Valueand sets it onLogUtilsthrough a static setter. The@Valuedefault (JOBM) matches the deleted class'sDEFAULT_JOBM_APPLICATION_NAME, and Helm never overrode it, so no new Helm key is required.Configuration
racm-application.yaml— removed theorg.sciserver.racm.loggingblock (nothing binds it onceLoggingConfigis gone) and addedlogging.rabbitmq.queuename. Thelogging.*section now matchesfileservice-application.propertiesexactly, which is the other service already on this pattern.application.properties(untracked, local dev) — uses the same standardlogging.*keys.Fixed
FileServiceRepository.java— replaced 2System.out.printfcalls with SLF4JLOG.warn().Public API
LogUtils.buildLog()and theLogBuilderfluent API are unchanged. All 11 files usingLogUtils.buildLog()required no modification.Behavior change worth a reviewer's attention
Emitted log messages previously carried
Host = "Kubernetes", set via the deleted config'sapplication-host.LoggerConfigdoes not setapplicationHost, soLogger.setupMessage()falls back toInetAddress.getLocalHost().getHostName()— the pod hostname.This is deliberate: it matches
fileservice. The services still emittingHost = Kubernetes(compute,logging-api,login-portal) do so through the legacyLog.ApplicationHostconfig-file path. Anyone with a saved query filtering RACM rows onHost = 'Kubernetes'will need to update it.Testing
Unit tests —
LogUtilsTestsadds 6 tests covering what this migration changed: which application name and message type eachLogUtilspath puts on the message.jobmLogUsesConfiguredJobmApplicationNameApplication= configured JOBM name,MessageType.JOBMracmLogKeepsLoggerApplicationNameApplicationnot overridden,MessageType.RACMfileServiceLogKeepsLoggerApplicationNameApplicationnot overridden,MessageType.FILESERVICEjobmErrorLogUsesConfiguredJobmApplicationNamelogError'sisJOBMbranch,MessageType.ERRORracmErrorLogKeepsLoggerApplicationNamelogErrorwithout the JOBM overrideloggerFailureDoesNotPropagateToCallerwrapSendingMessageswallowsSendMessagefailuresLogUtilsresolves itsLoggerthrough the staticApplicationContextheld byLog, so the tests populate that static with a mock context rather than starting a Spring context — no AspectJ weaving or EclipseLink enhancement needed, and therefore no-javaagentsetup. A bareLoggerhas no sink enabled, soSendMessagedoes no I/O while a Mockito spy captures the built message.loggerFailureDoesNotPropagateToCallerintentionally emits a"Failed to send message to sciserver logger"ERROR line on the console — that log line is the behavior under test, and the test is green when it appears../gradlew :racm:testpasses: 22 tests, 0 failures (16 pre-existing across 5 classes, plus these 6).:racm:buildandcheckstyleTestpass at the existing warning baseline.Sanity-checked against a mutation: commenting out
message.Application = jobmApplicationName;inlogJobmfails exactly one test withexpected:<JOBM_TEST> but was:<RACM>, confirming the tests fail when the behavior breaks.Smoke test — RACM was started in Eclipse against a local RACM database and the production login portal, and log messages were emitted with the expected
Application,Host, andMessageType. This is the part unit tests deliberately cannot cover: the mock-ApplicationContextfixture bypasses real Spring wiring, so only a live run confirms that deletingLoggingConfigleft no dangling injection point and thatLog.getLogger()resolves.Follow-ups (not in this PR)
LogUtils.fillMessageWithUserInfodereferencesRequestContextHolder.getRequestAttributes()with no null check, and it now runs unconditionally rather than behind the removedenabledguard. Unreachable today — RACM has no@Async,@Scheduled, or manually created threads, so everyLogUtilscall is on a request thread — but it deserves a guard.helm templateverification:helmwas not available in the dev environment used, so the chart edit is inspected but unrendered. Worth confirming in CI before deploy.🤖 Generated with Claude Code