diff --git a/Dockerfile b/Dockerfile index 1973204..0d1138c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,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 ENV UPDATE_CREDENTIALS=1 # see http://docs.geoserver.org/stable/en/user/production/container.html diff --git a/README.md b/README.md index caf5b5c..0fda430 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ you'll get a cleaned standard GeoServer (Version 2.19.3), which can be accessed - `GEOSERVER_ADMIN_USER` (String - supported since 2.19.x) Default is `admin` - `GEOSERVER_ADMIN_PASSWORD` (String - supported since 2.19.x) Default is `geoserver` - `UPDATE_CREDENTIALS` (0/1) If the credentials shall be updated on startup. Default is `0` + - `USE_STD_OUT_LOGGING` (0/1) If logs should be written to standard out. Default is `1` + - `GEOSERVER_LOG_LEVEL` See detailed description in section below. Default is `PRODUCTION` For detailed information check the sections below. @@ -101,6 +103,18 @@ Setting `UPDATE_CREDENTIALS` to `0` does not update the credentials on startup. docker run -e UPDATE_CREDENTIALS=0 -v $(pwd)/geoserver_data:/opt/geoserver_data -p 8080:8080 meggsimum/geoserver:latest ``` +## Log Level + +The environment variable `GEOSERVER_LOG_LEVEL` defines the log level of GeoServer. All predefined log levels of GeoServer are available. Default is `PRODUCTION`. + +```shell +docker run -e GEOSERVER_LOG_LEVEL=PRODUCTION -p 8080:8080 meggsimum/geoserver:2.21.0 +``` + +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.xml`. This profile would then be activated by setting the environment variable `GEOSERVER_LOG_LEVEL=PETER`. + +Note that starting from GeoServer version 2.21 on the logging has been rewritten completely. If you update from older GeoServer versions there might be adaptations necessary. More information are available in the changelog of GeoServer: https://geoserver.org/announcements/2022/05/24/geoserver-2-21-0-released.html#log4j-2-upgrade + ## Build this Image ```shell diff --git a/startup.sh b/startup.sh index a17519e..27d05e6 100755 --- a/startup.sh +++ b/startup.sh @@ -34,6 +34,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 " + ${GEOSERVER_LOG_LEVEL}_LOGGING.xml + ${STD_OUT_LOGGING_VALUE} +" > "${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"