Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FROM terrestris/tomcat:8.5.37
ARG GS_VERSION=2.20.4
ARG GS_DATA_PATH=./geoserver_data/
ARG ADDITIONAL_LIBS_PATH=./additional_libs/
ARG LOGGING_PROFILES_PATH=./logging_profiles/

# Environment variables
ENV GEOSERVER_VERSION=$GS_VERSION
Expand All @@ -17,6 +18,8 @@ ENV EXTRA_JAVA_OPTS="-Xms256m -Xmx1g"
ENV USE_VECTOR_TILES=0
ENV USE_WPS=0
ENV USE_CORS=0
ENV USE_STD_OUT_LOGGING=1
ENV GEOSERVER_LOG_LEVEL=PRODUCTION

# see http://docs.geoserver.org/stable/en/user/production/container.html
ENV CATALINA_OPTS="\$EXTRA_JAVA_OPTS -Dfile.encoding=UTF-8 -D-XX:SoftRefLRUPolicyMSPerMB=36000 -Xbootclasspath/a:$CATALINA_HOME/lib/marlin.jar -Xbootclasspath/p:$CATALINA_HOME/lib/marlin-sun-java2d.jar -Dsun.java2d.renderer=org.marlin.pisces.PiscesRenderingEngine -Dorg.geotools.coverage.jaiext.enabled=true"
Expand Down Expand Up @@ -96,6 +99,12 @@ RUN wget --no-check-certificate https://sourceforge.net/projects/geoserver/files
unzip ./$WPS_ZIP_NAME -d ./$WPS_NAME && \
mv ./$WPS_NAME/*.jar $WPS_EXTENSION_PATH

# LOGGING
ENV TMP_DIR_LOGGING_PROFILES=/temp_logging_profiles
# copy prefined logging profiles to temporary directory
# in the entry point script the logging profiles will be copied to the correct location
COPY ${LOGGING_PROFILES_PATH} ${TMP_DIR_LOGGING_PROFILES}

# cleanup
RUN apk del curl && \
rm -rf /tmp/* /var/cache/apk/*
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ In order to have individual admin credentials in your running container the envi
docker run -e GEOSERVER_ADMIN_USER=peter -e GEOSERVER_ADMIN_PASSWORD=abcd -p 18080:8080 meggsimum/geoserver:2.19.3
```

## Set Log Level and Standard Out Logging

These logging profiles(log levels) are available out of the box: `DEFAULT`, `PRODUCTION`, `QUIET`, `VERBOSE`

The environment variable `GEOSERVER_LOG_LEVEL` defines the log level of GeoServer.

```shell
docker run -e GEOSERVER_LOG_LEVEL=PRODUCTION -p 18080:8080 meggsimum/geoserver:2.19.3
```

It is possible to use custom logging profiles by adding them to the `logs` directory within the GeoServer data directory. The filename must match the pattern `PETER_LOGGING.properties`. This profile would then be activated by setting the environment variable `GEOSERVER_LOG_LEVEL=PETER`.

The environment variable `USE_STD_OUT_LOGGING` defines if logging should be done to standard out.

```shell
# example how to deactivate logging to standard out
docker run -e USE_STD_OUT_LOGGING=0 -p 18080:8080 meggsimum/geoserver:2.19.3
```

## Build this Image

```shell
Expand Down
30 changes: 30 additions & 0 deletions logging_profiles/DEFAULT_LOGGING.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## This log4j configuration file needs to stay here, and is used as the default logging setup
## during data_dir upgrades and in case the chosen logging config isn't available.

log4j.rootLogger=WARN, geoserverlogfile, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n


log4j.appender.geoserverlogfile=org.apache.log4j.RollingFileAppender
# Keep three backup files.
log4j.appender.geoserverlogfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.geoserverlogfile.layout=org.apache.log4j.PatternLayout
log4j.appender.geoserverlogfile.layout.ConversionPattern=%d %p [%c{2}] - %m%n

log4j.category.log4j=FATAL

log4j.category.org.geotools=WARN
log4j.category.org.geotools.factory=WARN
log4j.category.org.geoserver=INFO
log4j.category.org.vfny.geoserver=INFO
log4j.category.org.vfny.geoserver.config.web.tiles.definition.MultipleDefinitionsFactory=WARN
log4j.category.org.vfny.geoserver.global=INFO

log4j.category.org.springframework=WARN
log4j.category.org.apache.struts=WARN

log4j.category.org.geowebcache=INFO
41 changes: 41 additions & 0 deletions logging_profiles/PRODUCTION_LOGGING.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## This log4j configuration file needs to stay here, and is used as the default logging setup
## during data_dir upgrades and in case the chosen logging config isn't available.
##
## As GeoTools uses java.util.logging logging instead of log4j, GeoServer makes
## the following mappings to adjust the log4j levels specified in this file to
## the GeoTools logging system:
##
## Log4J Level java.util.logging Level
## --------------------------------------------
## ALL FINEST
## TRACE FINER
## DEBUG FINE (includes CONFIG)
## INFO INFO
## WARN/ERROR WARNING
## FATAL SEVERE
## OFF OFF

log4j.rootLogger=WARN, geoserverlogfile, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n


log4j.appender.geoserverlogfile=org.apache.log4j.RollingFileAppender
# Keep three backup files.
log4j.appender.geoserverlogfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.geoserverlogfile.layout=org.apache.log4j.PatternLayout
log4j.appender.geoserverlogfile.layout.ConversionPattern=%d %p [%c{2}] - %m%n

log4j.category.log4j=FATAL

log4j.category.org.geotools=WARN
log4j.category.org.geotools.factory=WARN
log4j.category.org.geoserver=WARN
log4j.category.org.vfny.geoserver=WARN

log4j.category.org.springframework=WARN

log4j.category.org.geowebcache=ERROR
22 changes: 22 additions & 0 deletions logging_profiles/QUIET_LOGGING.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## This log4j configuration file needs to stay here, and is used as the default logging setup
## during data_dir upgrades and in case the chosen logging config isn't available.
##
## As GeoTools uses java.util.logging logging instead of log4j, GeoServer makes
## the following mappings to adjust the log4j levels specified in this file to
## the GeoTools logging system:
##
## Log4J Level java.util.logging Level
## --------------------------------------------
## ALL FINEST
## TRACE FINER
## DEBUG FINE (includes CONFIG)
## INFO INFO
## ERROR/ERROR ERRORING
## ERROR SEVERE
## OFF OFF

log4j.rootLogger=OFF, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n
45 changes: 45 additions & 0 deletions logging_profiles/VERBOSE_LOGGING.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## This log4j configuration file needs to stay here, and is used as the default logging setup
## during data_dir upgrades and in case the chosen logging config isn't available.
##
## As GeoTools uses java.util.logging logging instead of log4j, GeoServer makes
## the following mappings to adjust the log4j levels specified in this file to
## the GeoTools logging system:
##
## Log4J Level java.util.logging Level
## --------------------------------------------
## ALL FINEST
## TRACE FINER
## DEBUG FINE (includes CONFIG)
## INFO INFO
## WARN/ERROR WARNING
## FATAL SEVERE
## OFF OFF

log4j.rootLogger=WARN, geoserverlogfile, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n

log4j.category.log4j=FATAL

log4j.appender.geoserverlogfile=org.apache.log4j.RollingFileAppender
# Keep three backup files.
log4j.appender.geoserverlogfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.geoserverlogfile.layout=org.apache.log4j.PatternLayout
log4j.appender.geoserverlogfile.layout.ConversionPattern=%d %p [%c{2}] - %m%n


log4j.category.org.geotools=TRACE
log4j.category.org.geotools.factory=TRACE
log4j.category.org.geotools.renderer=DEBUG
log4j.category.org.geoserver=TRACE
log4j.category.org.vfny.geoserver=TRACE
log4j.category.org.vfny.geoserver.config.web.tiles.definition.MultipleDefinitionsFactory=WARN
log4j.category.org.vfny.geoserver.global=TRACE

log4j.category.org.springframework=INFO
log4j.category.org.apache.struts=INFO

log4j.category.org.geowebcache=DEBUG
22 changes: 22 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh

# copy the predefined logging profiles to the GeoServer data directory
DIR_LOGGING_PROFILES=${GEOSERVER_DATA_DIR}logs
mkdir -p ${DIR_LOGGING_PROFILES}
mv ${TMP_DIR_LOGGING_PROFILES}/* ${DIR_LOGGING_PROFILES}

ADDITIONAL_LIBS_DIR=/opt/additional_libs/

# path to default extensions stored in image
Expand Down Expand Up @@ -34,6 +39,23 @@ if [ -d "$ADDITIONAL_LIBS_DIR" ]; then
cp $ADDITIONAL_LIBS_DIR/*.jar $CATALINA_HOME/webapps/$APP_PATH_PREFIX"geoserver/WEB-INF/lib/"
fi

# logging level
# inspired by Kartoza GeoServer Docker image
# https://github.com/kartoza/docker-geoserver/blob/f40770a5bbb4f29dc0d107a05aafb5f0da09164a/scripts/functions.sh#L269-L276
echo "Applying logging level and usage of standard out of logs"

STD_OUT_LOGGING_VALUE=false
if [ "${USE_STD_OUT_LOGGING}" == 1 ]; then
STD_OUT_LOGGING_VALUE=true
fi

echo "<logging>
<level>${GEOSERVER_LOG_LEVEL}_LOGGING.properties</level>
<stdOutLogging>${STD_OUT_LOGGING_VALUE}</stdOutLogging>
</logging>" > "${GEOSERVER_DATA_DIR}"/logging.xml

echo "Set log level to ${GEOSERVER_LOG_LEVEL}"

# ENABLE CORS
if [ "$USE_CORS" == 1 ]; then
echo "Enabling CORS for GeoServer"
Expand Down