1

I want to log messages from my Snmptrapd to a logfile, but my deamon don't understands the logOption token?

I try to use this line in my configuration (/etc/snmp/snmptrapd.conf):

logOption -f "/var/log/snmptrapd.log"

But I get this warning:

/etc/snmp/snmptrapd.conf: line 3: Warning: Unknown token: logOption

Does anyone know which option is valid? And how to log to an external file (and not the syslog).

I am using NET-SNMP Version: 5.7.3 and Ubuntu version 18.04.3.

Thank you for your help!

Jarne
  • 101

1 Answers1

4

I'm late to this party, but I ran into this today and thought I'd throw my two cents in. According to some posts I've read, this is because "logOption" is called by another library (in this case, "snmp") which needs to be specified in the config file. The man pages make no mention of this, but it should look like this in /etc/snmp/snmptrapd.conf:

[snmp] logOption -f "/var/log/snmptrapd.log"

Hopefully that helps someone else.

  • Hello, thank you for your answer, but I just removed this line in my configuration and restarted my deamon without any errors. – Jarne Feb 13 '20 at 08:32
  • 1
    adding [snmp] in front of logOption works for me with NET-SNMP Version: 5.7.3 works like a charm! Really appreciate! The quotation marks " seems not needed, in my system of Ubuntu 18.04 – Yu Shen Jun 26 '20 at 03:55
  • On 22.04 use this to log to syslog: [snmp] logOption sd – Dan Jun 30 '23 at 12:25