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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<logging>
<level>${GEOSERVER_LOG_LEVEL}_LOGGING.xml</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