decke/smtprelay

Option to disable logfile

jantari opened this issue · 3 comments

Hi, is it possible to disable the manual logfile the program writes?

I would run this as a systemd service, and in that case systemd-journald automatically captures the STDOUT of the program and keeps it in a log, with control over rotation and standardized commands to get the logs.

I tried commenting out the config line:

;logfile = /var/log/smtprelay.log

but it just defaulted to the same path again. I'm trying to NOT have this logfile at all, because it would just take up space and when I try to start my systemd service I get:

● smtprelay.service - Simple Golang SMTP relay/proxy server
     Loaded: loaded (/etc/systemd/system/smtprelay.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-03-17 14:59:20 CET; 6s ago
    Process: 34965 ExecStart=/usr/local/bin/smtprelay --config /etc/smtprelay/config.ini (code=exited, status=1/FAILURE)
   Main PID: 34965 (code=exited, status=1/FAILURE)

Mar 17 14:59:20 myserver systemd[1]: Started Simple Golang SMTP relay/proxy server.
Mar 17 14:59:20 myserver smtprelay[34965]: 2021/03/17 14:59:20 Error opening logfile: open /var/log/smtprelay.log: permission denied
Mar 17 14:59:20 myserver systemd[1]: smtprelay.service: Main process exited, code=exited, status=1/FAILURE
Mar 17 14:59:20 myserver systemd[1]: smtprelay.service: Failed with result 'exit-code'.

because obviously the system account the service runs as doesn't have any unneeded permissions in that directory (/var/log).

Hi @jantari. Am I correct in assuming you're running the latest-released v1.5.0?

We just recently merged #15 which, among other things, changes the default log file to STDERR. This change was made primarily with running as a systemd service in mind.

So you can either wait for the next release (I'm not sure what that timeline looks like; @decke will have to fill-in here), or you can pull the source and build from master yourself.

I'm going to close this issue because I think it is already resolved, but please feel free to comment if there's anything else! Thanks!

Thanks for the quick response, yes I am using 1.5.0

I'll wait for the next release and try logging to /dev/null or something in the meantime as a workaround.

decke commented

I planned to have a 1.6.0 release within the next few weeks but would like to discuss and merge the open PRs before that.