Skip to content

Commit

Permalink
Add a "container friendly" log4j2 cfg and output compose dspace log t…
Browse files Browse the repository at this point in the history
…o console (DSpace#8828)

Co-authored-by: Tim Donohue <[email protected]>
  • Loading branch information
mark-cooper and tdonohue authored Sep 13, 2023
1 parent 7fc9135 commit b6d20ee
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
# proxies.trusted.ipranges: This setting is required for a REST API running in Docker to trust requests
# from the host machine. This IP range MUST correspond to the 'dspacenet' subnet defined above.
proxies__P__trusted__P__ipranges: '172.23.0'
LOGGING_CONFIG: /dspace/config/log4j2-container.xml
image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-latest-test}"
build:
context: .
Expand Down
65 changes: 65 additions & 0 deletions dspace/config/log4j2-container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Logging configuration for DSpace container (matches log4j2.xml but to console, removing file refs & most comments) -->
<Configuration strict='true'
xmlns='http://logging.apache.org/log4j/2.0/config'>

<Properties>
<Property name='loglevel.dspace'>INFO</Property>
<Property name='loglevel.other'>INFO</Property>
</Properties>

<Appenders>
<!-- A1 is for most DSpace activity -->
<Appender name='A1'
type='Console'

>
<Layout type='PatternLayout'
pattern='%d %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/>
</Appender>

<!-- A2 is for the checksum checker -->
<Appender name='A2'
type='Console'>
<Layout type='PatternLayout'
pattern='%m%n'/>
</Appender>
</Appenders>

<Loggers>

<!-- Most parts of DSpace -->
<Logger name='org.dspace'
level='${loglevel.dspace}'
additivity='false'>
<AppenderRef ref='A1'/>
</Logger>

<!-- The checksum checker -->
<Logger name='org.dspace.checker'
level='INFO'
additivity='false'>
<AppenderRef ref='A2'/>
</Logger>

<!-- Block services logging except on exceptions -->
<Logger name='org.dspace.kernel'
level='ERROR'/>
<Logger name='org.dspace.services'
level='ERROR'/>
<Logger name='org.dspace.servicemanager'
level='WARN'/>
<Logger name='org.dspace.providers'
level='ERROR'/>
<Logger name='org.dspace.utils'
level='ERROR'/>

<!-- Block passwords from being exposed in Axis logs. (DEBUG exposes passwords in Basic Auth) -->
<Logger name='org.apache.axis.handlers.http.HTTPAuthHandler'
level='INFO'/>
<!-- Anything not a part of DSpace -->
<Root level='${loglevel.other}'>
<AppenderRef ref='A1'/>
</Root>
</Loggers>
</Configuration>

0 comments on commit b6d20ee

Please sign in to comment.