Skip to content

[FEAT] DELUGE_LOGFILE (or similar) to write log to file instead of stdout #218

@mihawk90

Description

@mihawk90

Is this a new feature request?

  • I have searched the existing issues

Wanted change

The container already has an option for DELUGE_LOGLEVEL in place to set the log level. However, setting this to debug will get extremely spammy very quickly if you have a lot of active torrents.

It would be nice to get a complementary DELUGE_LOGFILE environment variable corresponding to --logfile:

       -l file, --logfile=file
              Output to specified logfile instead of stdout

Another option that might be welcome is --logrotate:

       --logrotate[=max-size]
              Enable logfile rotation, with optional maximum logfile size, default: 2M (Logfile rotation count is 5)

Reason for change

Having a logfile makes it easier to process logs later on, after shutting down the container, or simply to save the output for later upload.

Proposed code change

This is untested, but should work:

--- run 2025-04-22 19:47:24.047468461 +0200
+++ run-patched 2025-04-22 19:52:53.263299033 +0200
@@ -3,6 +3,10 @@
 
 DELUGE_LOGLEVEL=${DELUGE_LOGLEVEL:-info}
 
+if [ "${DELUGE_LOGFILE}" != "" ]; then
+    DELUGE_LOGFILE = "--logfile='${DELUGE_LOGFILE}'"
+fi
+
 if [[ -f /config/core.conf ]]; then
     DELUGED_PORT=$(grep '"daemon_port"' /config/core.conf | tr -cd "[:digit:]")
 fi
@@ -10,9 +14,9 @@
 if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
     exec \
         s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGED_PORT:-58846}" \
-            s6-setuidgid abc /usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}"
+            s6-setuidgid abc /usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}" ${DELUGE_LOGFILE}
 else
     exec \
         s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGED_PORT:-58846}" \
-            /usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}"
+            /usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}" ${DELUGE_LOGFILE}
 fi

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions