-
Notifications
You must be signed in to change notification settings - Fork 321
view logs
This is a guide to viewing and posting WeeWX log messages. It describes
- How to produce a useful log report
- Where to find log messages from WeeWX
- Log levels
- How to test your system logger
If you want to change the logging configuration, see the Wiki article about How to customize logging.
This section shows how to create a log report that you can give to others, for example, when you need to include the log in a posting to the user group.
-
Stop WeeWX
init system how to stop weewxd systemd sudo systemctl stop weewxsysV sudo /etc/init.d/weewx stoplaunchd sudo launchctl unload /Library/LaunchDaemons/com.weewx.weewxd.plist -
Enable debug. Set
debug=1in the configuration file (typicallyweewx.conf). Settingdebug=2will give you even more information, which can be helpful when debugging RESTful uploads and FTP. However, it will generate a lot of log entries. -
View and save the log
In a terminal window, use
tailorjournalctlto watch the system log, combined withteeto save what you see to a separate file. This will allow you to see the log in real time, while saving a copy to the file/tmp/mylog.logger location of system log command operating system syslog /var/log/messagessudo tail -f /var/log/messages | tee /tmp/mylogRedhat, Fedora, CentOS, Rocky syslog /var/log/syslogsudo tail -f /var/log/syslog | tee /tmp/mylogDebian, Ubuntu, Raspian, MacOS journald sudo journalctl -u weewx -f | tee /tmp/mylogRedhat, SUSE, Debian -
Start WeeWX and watch the log
In a different terminal, start
weewxdas you watch the log output in the first terminal.init system how to start weewxd systemd sudo systemctl start weewxsysV sudo /etc/init.d/weewx startlaunchd sudo launchctl load /Library/LaunchDaemons/com.weewx.weewxd.plist -
Let WeeWX run through at least the first reporting cycle (usually 5-10 minutes).
-
Attach the created file (
/tmp/mylog) to your post to weewx-user, or put it on a cloud service like pastebin.com and include a link.
In its default configuration, WeeWX sends log messages to the system logging
facility. This means that the system is responsible for things such as ensuring
that running multiple instances of weewxd do not corrupt the log, and for
rotating log files so that they do not fill up the disks.
There are many different system loggers available. For example, linux systems
have syslog, rsyslog, syslog-ng, and/or systemd-journald, BSD systems
typically have syslog and newsyslog.
But basically there are two types: journald (systems that use systemd) and syslog (everything else)
On systems that use systemd, there is a program called systemd-journald that manages some (or all) of the system logging. On some systems that use systemd, there is no syslog — they use systemd-journald exclusively. Others include both syslog and systemd-journald. On systems with systemd-journald, you might be able to use the journalctl tool to view messages from WeeWX.
Here are some examples of using journalctl:
# look at the messages only from the weewx service
sudo journalctl -u weewx
# view all of the message contents, not just the first few words of each line
sudo journalctl -u weewx | more
# view the messages from the weectl utility
sudo journalctl -t weectl
# view messages from both weewxd and weectl
sudo journalctl -t weewxd -t weectl
# view messages from every WeeWX process as they arrive and save to file
sudo journalctl -f -t weewxd -t weectl | tee ~/weewx.log
On systems that use syslog, the logger saves the log messages to a file. Some operating systems save to file /var/log/syslog (Debian, Ubuntu, MacOS), while others use /var/log/messages (Redhat, Fedora, CentOS, Rocky, FreeBSD, OpenBSD). In some configurations, you might see messages from WeeWX in both /var/log/syslog and /var/log/messages.
You can use standard tools such as head, tail, more, or less to view these messages.
Here are some examples:
# look at the last 10 messages
sudo tail -10 /var/log/syslog
# look at the first 20 messages, just from weewxd
sudo grep weewxd /var/log/messages | head -20
# watch all of the messages from weewxd as they arrive (ctrl-c to stop)
sudo tail -f /var/log/messages | grep weewxd
# watch the messages from weectl as they arrive, and save them to a file weectl.log
sudo tail -f /var/log/syslog | grep weectl > ~/weectl.log
# watch messages from every WeeWX process and save them to a file
sudo tail -f /var/log/syslog | grep wee | tee ~/weewx.log
On many Linux systems, the sudo is required, since the system logs are visible only to the system administration accounts.
The system logging facility has different log levels. For example, a message about something that is important, but non-fatal, might be a WARNING, a message about normal report generation might be INFO, and a troubleshooting message might be DEBUG (if you enable verbose logging). Messages about events that adversely affect WeeWX operation will typically be at the ERROR level. These messages include a mis-configured driver or extension, a failed attempt to upload data, or failure to save data to the database.
When you enable debug in the WeeWX configuration file, this enables many more messages, but at the DEBUG level. These messages can help you diagnose problems with hardware, report generation, and network issues.
In a default, functional WeeWX installation, the WeeWX log level is INFO, meaning that WeeWX will emit INFO, WARNING, and ERROR messages. So if you do not see messages from WeeWX in your system logs, be sure that your operating system is recording at least log level INFO.
Most Linux systems are configured to record all of the log levels. BSD systems such as FreeBSD and OpenBSD are configured to record only error messages. The article about How to customize logging explains how to change a BSD logging configuration.
There is a program called logger that you can use to test the behavior of your system's logging facilities.
# view all of the options to the logger program
man logger
# send a simple message with priority 'info'
logger -p info "this is my first message"