How to limit syslog logging

211 views
Skip to first unread message

LeaF

unread,
Jan 20, 2021, 1:38:59 PM1/20/21
to weewx-user

I have a question regarding what goes into the /var/log/syslog file.

I’m running the latest version of weewx on a Raspberry Pi 4.  My station is a Peet Bros Ultimeter 100. I also added a Adafruit BME280 breakout board to measure pressure and humidity. 

This all works very well.  Thank you

When I run sudo tail -f /var/log/syslog, there appears to be three entries per second being written to the log file.  So as you can imagine, the log file has a lot of info that I don’t want in there.  Any errors are being written to weewx.log file.

How can I limit what is going to the log file so they don’t grow so large?  I looked at rsyslog.conf, but don’t know if this is the correct place to limit the log entries.

Example, one entry into log file:

 Jan 20 10:22:47 WeatherPi /weewxd: bme280: {'dateTime': 1611166967, 'usUnits': 1, 'windSpeed': 0.0, 'windDir': 55.058796, 'outTemp': 38.300000000000004, 'rain_total': 0.5, 'barometer': None, 'inTemp': None, 'outHumidity': 77.02371597125266, 'inHumidity': None, 'day_of_year': 19, 'minute_of_day': 620, 'daily_rain': 0.0, 'wind_average': 0.0, 'rain': 0.0, 'pressure': 29.53154056121909}

Thanks for your help.

Lee

Tom Keffer

unread,
Jan 20, 2021, 1:50:01 PM1/20/21
to weewx-user
It looks like an extension you are using, bme280, is what is creating the chatter. Unfortunately, from the little log snippet you gave, it does not appear to be WeeWX V4 compliant, so muzzling it will not be as easy as a weewx.conf setting. You could ask the author to update it to V4, then you could follow the directions in the Wiki article WeeWX V4 and logging.

OTOH, fortunately, it looks like the log entry is a debug entry, so setting debug=0 in weewx.conf should help reduce the number of entries.

-tk



--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/7c9cae95-4bcd-4dd6-b293-2113d6a5054cn%40googlegroups.com.

LeaF

unread,
Jan 20, 2021, 1:54:19 PM1/20/21
to weewx-user
tk
Thanks for the observation.  I'll do some snooping around the bme280 and see what I can find.

(It's not only syslog getting overwhelmed with entries, but debug and user log files are filled with the same info)

Thanks
Lee

Tom Keffer

unread,
Jan 20, 2021, 1:58:46 PM1/20/21
to weewx-user
Those things are generally set in /etc/rsyslog.d

LeaF

unread,
Jan 20, 2021, 2:11:22 PM1/20/21
to weewx-user
So taking your advice, I looked into the bme280wx.py file and noticed that there were a number of places where it was writing out information to various file; syslog, debug and user.  When I commented those lines out, voila no more excessive logging.
Thanks again tk
Lee

Mks Mk

unread,
Jan 21, 2021, 12:26:55 PM1/21/21
to weewx-user
Dear Leaf
need your help to correct my system because I am having the same issue of logging so kindly advice of the correction to done to bme280wx.py and which lines to be commented.

thanks

Message has been deleted

Mks Mk

unread,
Jan 22, 2021, 1:32:01 PM1/22/21
to weewx-user
Found these line in the file bme280wx.py
---------------------------------------
def logmsg(level, msg):
    syslog.syslog(level, 'bme280: %s' % msg)

def logdbg(msg):
    logmsg(syslog.LOG_DEBUG, msg)

def loginf(msg):
    logmsg(syslog.LOG_INFO, msg)

def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
-------------------------------------

I changed 2nd line as suggested

#def logdbg(msg):
#    logmsg(syslog.LOG_DEBUG, msg)


started weewx and fail to run with this log below

Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__: Caught unrecoverable exception:
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****  global name 'logdbg' is not defined
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****  Traceback (most recent call last):
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd", line 154, in main
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****      engine.run()
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 210, in run
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****      self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 245, in dispatchEvent
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****      callback(event)
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****    File "/usr/share/weewx/user/bme280wx.py", line 107, in new_loop_packet
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****      logdbg(packet)
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****  NameError: global name 'logdbg' is not defined
Jan 22 21:05:13 raspberrypi weewx[7491] CRITICAL __main__:     ****  Exiting.

I am not sure but I may have different bme280wx.py than yours.
I used this link (https://gitlab.com/wjcarpenter/bme280wx) during the installation for this driver and it worked fine with weewx 3.92 but when (https://github.com/merbanan/rtl_433) made alot of changes for Acurite devices and no one seem to be looking after (https://github.com/matthewwall/weewx-sdr) (sdr.py) and weewx got updated further thats where things got lost and we are struggling with these problems.

I truly appreciate your help

On Friday, January 22, 2021 at 8:01:05 PM UTC+3 LeaF wrote:
Edit the bme280wx.py file and comment out anything you don't want logged.  For example, I commented out the following lines in the file:

 #def logdbg(msg):

#    logmsg(syslog.LOG_DEBUG, msg).

You'll need to review the entire file for other lines that are writing to a log file and determine whether or not you want that information logged.

vince

unread,
Jan 22, 2021, 1:59:19 PM1/22/21
to weewx-user
I think you want to comment out line 107 (where it says 'to' log) and 'not' comment out lines 15+16 (where it says 'how to' log)

Mks Mk

unread,
Jan 22, 2021, 7:01:57 PM1/22/21
to weewx-user
Vince 

I changed line 107 in (bme280wx.py)  file to

#        logdbg(packet)

unfortunately the log problem still filling up files in (/var/log) and I am puzzled because it did work for (LeaF) system but not mine !..........................may be there are differents somewhere in our weewx arsenals

I really appreciate your help and support in this matter.

vince

unread,
Jan 22, 2021, 7:06:06 PM1/22/21
to weewx-user
We'd have to see 'exactly' what code you have installed now in order to help.   At this point we've seen so many partial descriptions that it's impossible to know what exactly you're currently running and what error messages you are seeing when you run that code.

gjr80

unread,
Jan 22, 2021, 7:16:42 PM1/22/21
to weewx-user
If it's this one then the only change that is needed is to change the loginf() call at line 78 to logdbg(). Everything else should be left untouched. Commenting out logging to fix a chatty log is really a case of cutting off your nose to spite your face. Just like restarting WeeWX daily, far better to engineer out the problem.

Gary

Mks Mk

unread,
Jan 22, 2021, 8:37:31 PM1/22/21
to weewx-user
Commenting out line 78 or line 107 only did not work, but Commenting out (line 78 & 107) did the trick. no more unnecessary writing to (/var/log)

Thank you vince & gjr80

gjr80

unread,
Jan 22, 2021, 8:50:58 PM1/22/21
to weewx-user
Not sure why you are thanking me, you took no notice of what I suggested. Commenting out log lines is a poor choice, in future if you ever want to troubleshoot you have no means of obtaining any meaningful log info unless you again modify source code. A better solution is to change the log level of the noisy log output as i suggested so that it is only logged when you run WeeWX with debug = 1.

Gary
Message has been deleted

Mks Mk

unread,
Jan 22, 2021, 9:26:55 PM1/22/21
to weewx-user
I am realy sorry I missed to mention that changing line 78

        loginf('BME280 data %s' % bme280data)
to
        logdbg('BME280 data %s' % bme280data)

did not work

gjr80

unread,
Jan 22, 2021, 9:36:12 PM1/22/21
to weewx-user
Did you have debug = 0 in weewx.conf and did you restart WeeWX?

Gary

Mks Mk

unread,
Jan 22, 2021, 9:43:02 PM1/22/21
to weewx-user
Yes. debug =0 in weewx.conf

anytime I do changes to a driver I follow these steps

sudo /etc/init.d/weewx stop

*make the changes and save*

sudo /etc/init.d/weewx start

gjr80

unread,
Jan 22, 2021, 10:09:59 PM1/22/21
to weewx-user
Ah, you are running WeeWX v4 and this driver uses WeeWX v3 (legacy) logging, hence the lack of control. Try this version of bme280wx.py, I've changed the logging to v4 logging and changed the offending loginf to logdbg. Rename your old bme280wx.py to say bme280wx_orig.py and then copy the attached bme280wx.py in its place. Restart WeeWX and you should have a quieter log, if you want to turn on the debug logging to see the bme28 data in the log just set debug = 1 in weewx.conf and restart WeeWX.

If the driver fails because of an error on my behalf you can revert to the copy you just made.

Gary
bme280wx.py

Mks Mk

unread,
Jan 22, 2021, 10:57:27 PM1/22/21
to weewx-user
Gary

Can't thank you enough
the updated (bme280wx.py) solved my problem and it is working great and no more logging issue.
Reply all
Reply to author
Forward
0 new messages