DSpace9.3/fix(logging): write dspace.log inside the container again (port of #1392) - #1410
Merged
Merged
Conversation
Port of #1392 (MENDELU/fix-dspace-log-to-file, merged to customer/mendelu) to dtq-dev-9-base. Everything the backend logs comes out as container stdout only, and [dspace.dir]/log/dspace.log is never created. log4j2-container.xml is console-only by design upstream -- its header says "matches log4j2.xml but to console, removing file refs" and both appenders are type='Console'. log4j2-cli.xml is untouched and already writes dspace-cli.log/checker.log, which is why /dspace/log exists in the container but holds no dspace.log. A1 becomes the same RollingFile appender log4j2.xml uses on this branch, and a separate STDOUT appender echoes the same events to the console so "docker logs" keeps working unchanged. Adapted from #1392 for this branch: filePattern has no ".gz" suffix, to match dspace/config/log4j2.xml here, which rolls over to plain dspace.log-yyyy-MM-dd. The commented-out sample deletion policy glob was adjusted to match. Two optional knobs, both defaulting to current behaviour: - DSPACE_LOG_DIR log directory, default /dspace/log - DSPACE_LOG_CONSOLE_LEVEL level of the stdout copy, default INFO Log levels, the checksum-checker appender and the blocked org.dspace.* loggers are left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Restores file-based logging inside the container by updating the container-specific Log4j2 configuration to write dspace.log (with daily rollover) while still mirroring logs to container stdout for docker logs compatibility.
Changes:
- Add a
RollingFileappender tolog4j2-container.xmlto create/write${log.dir}/dspace.logwith daily rollover. - Add a separate
STDOUTconsole appender with a configurable threshold (DSPACE_LOG_CONSOLE_LEVEL) to control verbosity of mirrored container output.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jr-rk
approved these changes
Aug 11, 2026
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.
Port of #1392 (
MENDELU/fix-dspace-log-to-file, merged tocustomer/mendelu) todtq-dev-9-base.Problem
Everything the backend logs comes out as container stdout, and
[dspace.dir]/log/dspace.logis never created. Anything that expectsdspace.log— support tickets,grep-based debugging, log shipping, the reflex of every DSpace admin — has nothing to read.This is not theoretical on this branch. Diagnosing a live CLARIN 9.3 issue on dev-6 (
dspace8603) hit exactly this wall:The code under investigation (
SpecialItemService.getUploadedMetadata()) swallows exceptions into alog.error(e)and returns an empty document, so the failure is only visible in the log — and the log was not where anyone would look for it.Cause
The container is started with
(
docker/docker-compose-rest.yml:54in thedtq-dev-9-basefrontend stack, anddocker-compose-ci.yml:35). Spring Boot mapsLOGGING_CONFIG→logging.configand hands that file to Log4j2.log4j2-container.xmlis console-only by design upstream — its own header says "matches log4j2.xml but to console, removing file refs & most comments", and both of its appenders aretype='Console'. The file destination is not misconfigured; it simply does not exist in that config. Note this is only the Spring Boot webapp:log4j2-cli.xmlis untouched and already writesdspace-cli.log/checker.log, which is exactly why/dspace/logexists in the container but has nodspace.login it.Fix
log4j2-container.xmlnow carries the sameRollingFileappender thatlog4j2.xmluses on this branch, and echoes the same events to stdout through a separate appender, sodocker logs dspace8603keeps working exactly as it does today./dspace/log/dspace.logdocker logs dspace8603Two knobs, both optional and both defaulting to current behaviour:
DSPACE_LOG_DIR— log directory, default/dspace/log. That is wheredspace.dirpoints in the image (Dockerfile:ENV dspace__P__dir=/dspace), so the default is correct as shipped.DSPACE_LOG_CONSOLE_LEVEL— level of the stdout copy, defaultINFO. Set it toWARNorOFFto stop duplicating everything into the Docker json-file log oncedspace.logis being collected.dspace.logalways receives everything regardless.Log levels, the checksum-checker appender and the blocked
org.dspace.*loggers are deliberately left alone.Adapted from #1392 for this branch
One deliberate difference. #1392 rolls over to
dspace.log-yyyy-MM-dd.gz; this branch's owndspace/config/log4j2.xmlrolls over to plaindspace.log-yyyy-MM-dd:<!-- dspace/config/log4j2.xml on dtq-dev-9-base --> filePattern="${log.dir}/dspace.log-%d{yyyy-MM-dd}"Since the whole point is parity with
log4j2.xml, the.gzsuffix is dropped here and the commented-out sample deletion policy glob was adjusted to match (dspace.log-*). The existingdspace-cli.log-*files in the container are uncompressed too, so this is also consistent with what is already on disk.Everything else is identical to #1392.
Verified on this branch
log4j.versionis 2.25.4 inpom.xml— the same version MENDELU/fix(logging): write dspace.log inside the container again #1392 was verified against, so its testing carries over.DockerfilesetsENV dspace__P__dir=/dspace, so the/dspace/logdefault resolves correctly as shipped.docker/docker-compose-rest.yml:54does setLOGGING_CONFIGto this file, so the change takes effect on this stack rather than being inert.log4j2-container.xmlis byte-identical ondtq-devanddtq-dev-9-base, so the port applies to the same starting point MENDELU/fix(logging): write dspace.log inside the container again #1392 patched.A1:RollingFile,STDOUT:Console,A2:Console, withfileName=${log.dir}/dspace.logandfilePattern=${log.dir}/dspace.log-%d{yyyy-MM-dd}. Worth stating explicitly because this file isstrict='true'— a parse failure would silently fall back to a default console config.Follow-up (required for this to be useful beyond the current container)
/dspace/logis still in the container's writable layer, sodspace.logis wiped on every recreate — i.e. exactly when you redeploy after an incident. Making it outlive the container needs a volume in the frontend stack's compose for this instance; that is out of scope here. This PR is correct and safe on its own, it just cannot make the file persistent by itself.Also worth checking after merge: if the deploy overlay on dev-6 (
/opt/dspace-envs/8603/docker-compose-rest.yml) pinsLOGGING_CONFIGto something else, it wins over the compose default and this change will have no effect there.