Skip to content

Commit 2a1b41b

Browse files
authored
Merge pull request #1410 from dataquest-dev/ufal/port-1392-dspace-log-9-base
DSpace9/fix(logging): write dspace.log inside the container again (port of #1392)
2 parents 3505ee9 + 9e943f0 commit 2a1b41b

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

dspace/config/log4j2-container.xml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,70 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- Logging configuration for DSpace container (matches log4j2.xml but to console, removing file refs & most comments) -->
2+
<!-- Logging configuration for DSpace container.
3+
4+
Writes [dspace.dir]/log/dspace.log exactly like log4j2.xml does outside of a container, and
5+
mirrors the same events to stdout so that "docker logs" keeps working. Point the container at
6+
this file with the LOGGING_CONFIG environment variable (see docker-compose-rest.yml).
7+
8+
NOTE: /dspace/log only survives a container recreate when it is mounted as a volume. -->
39
<Configuration strict='true'
410
xmlns='http://logging.apache.org/log4j/2.0/config'>
511

612
<Properties>
13+
<!-- Log file directory. "dspace.dir" is fixed to /dspace in the image (see Dockerfile),
14+
so the log directory is /dspace/log. Override with the DSPACE_LOG_DIR env variable
15+
when the container installs DSpace somewhere else. -->
16+
<Property name='log.dir'>${env:DSPACE_LOG_DIR:-/dspace/log}</Property>
17+
18+
<!-- Log level for all DSpace-specific code (org.dspace.*)
19+
Possible values (from most to least info):
20+
DEBUG, INFO, WARN, ERROR, FATAL -->
721
<Property name='loglevel.dspace'>INFO</Property>
22+
23+
<!-- Log level for other third-party tools/APIs used by DSpace
24+
Possible values (from most to least info):
25+
DEBUG, INFO, WARN, ERROR, FATAL -->
826
<Property name='loglevel.other'>INFO</Property>
27+
28+
<!-- Level of the copy that is echoed to the container console ("docker logs").
29+
dspace.log always receives everything; raise this to WARN, or set it to OFF, to keep
30+
the container output small once dspace.log is being collected. -->
31+
<Property name='loglevel.console'>${env:DSPACE_LOG_CONSOLE_LEVEL:-INFO}</Property>
932
</Properties>
1033

1134
<Appenders>
1235
<!-- A1 is for most DSpace activity -->
1336
<Appender name='A1'
14-
type='Console'
37+
filePattern='${log.dir}/dspace.log-%d{yyyy-MM-dd}'
38+
type='RollingFile'
39+
fileName='${log.dir}/dspace.log'
1540

1641
>
42+
<!-- NOTE: The %equals patterns are providing a default value of "unknown" if "correlationID" or
43+
"requestID" are not currently set in the ThreadContext. -->
44+
<Layout type='PatternLayout'
45+
pattern='%d %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/>
46+
<policies>
47+
<policy type='TimeBasedTriggeringPolicy'>yyyy-MM-dd</policy>
48+
</policies>
49+
<!-- Sample deletion policy: keep last 30 archived files
50+
<DefaultRolloverStrategy>
51+
<Delete basePath='${log.dir}'>
52+
<IfFileName glob='dspace.log-*'/>
53+
<IfAccumulatedFileCount exceeds='30'/>
54+
</Delete>
55+
</DefaultRolloverStrategy>
56+
-->
57+
</Appender>
58+
59+
<!-- STDOUT echoes A1 to the container console, so that "docker logs" is not blind -->
60+
<Appender name='STDOUT'
61+
type='Console'>
1762
<Layout type='PatternLayout'
1863
pattern='%d %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/>
64+
<Filters>
65+
<Filter type='ThresholdFilter'
66+
level='${loglevel.console}'/>
67+
</Filters>
1968
</Appender>
2069

2170
<!-- A2 is for the checksum checker -->
@@ -33,6 +82,7 @@
3382
level='${loglevel.dspace}'
3483
additivity='false'>
3584
<AppenderRef ref='A1'/>
85+
<AppenderRef ref='STDOUT'/>
3686
</Logger>
3787

3888
<!-- The checksum checker -->
@@ -60,6 +110,7 @@
60110
<!-- Anything not a part of DSpace -->
61111
<Root level='${loglevel.other}'>
62112
<AppenderRef ref='A1'/>
113+
<AppenderRef ref='STDOUT'/>
63114
</Root>
64115
</Loggers>
65116
</Configuration>

0 commit comments

Comments
 (0)