How to configure logging while using XWiki in container

Hello :waving_hand:

I’m trying to launch XWiki from a container image and have a custom logback config to store the log files in the filesystem instead of the console.

When I try to launch XWiki without this config (using the logging default config), it works fine, I use this command

podman run --replace -it --name=xwiki --volume=$HOME/xwiki/data:/usr/local/xwiki:z --env=CONTEXT_PATH=wikis --env=DB_USER=xwiki --env=DB_DATABASE=xwiki --env=DB_HOST=localhost --network=host docker.io/library/xwiki:17.10.3-postgres-tomcat

When I try to map my local logback config INTO the container, I use this command below

podman run --replace -it --name=xwiki --volume=$HOME/xwiki/data:/usr/local/xwiki:z --volume=$HOME/xwiki/logback.xml:/usr/local/tomcat/webapps/wikis/WEB-INF/classes/logback.xml:z --env=CONTEXT_PATH=wikis --env=DB_USER=xwiki --env=DB_DATABASE=xwiki --env=DB_HOST=localhost --network=host docker.io/library/xwiki:17.10.3-postgres-tomcat

and I get this output

Configuring XWiki...
Setting environment variables
  Deploying XWiki in the 'wikis' context
Replacing environment variables in files
sed: can't read /usr/local/tomcat/webapps/wikis/WEB-INF/hibernate.cfg.xml: No such file or directory

Anyone knows what is going on? Because I try to customize logback.xml, do I need to also map as well xwiki.cfg, xwiki.properties and hibernate.cfg.xml ?

Thank you

Created Fixing case when we using a non root context path by flopma · Pull Request #82 · xwiki/xwiki-docker · GitHub to provide a fix

1 Like

In the file xwiki-docker/template/xwiki/docker-entrypoint.sh at master · xwiki/xwiki-docker · GitHub

The command

  mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/\$CONTEXT_PATH

is broken. When mapping files like logback.xml from the host into the container, the move command will move the folder ROOT as a sub-folder of $CONTEXT_PATH.

cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/

Thx! The PR was merged.