-
Notifications
You must be signed in to change notification settings - Fork 305
view logs
This is a guide to viewing WeeWX log messages. It describes some of the configurations you might encounter when you use the system logging facility, as well as the steps for producing a log report suitable for posting to weewx-user
If you want to change the logging configuration, see the Wiki article about How to customize logging
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
. Most of these save the log messages to a file, and the system takes care of rotating the files so that they do not fill up the local storage. Some can be configured to send the logs to a remote logging server, which can make managing multiple machines much easier, and provides security benefits as well.
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.
On systems that use syslog
, when weewxd
or any service or extension emits a log message, that message goes to the system's logger. The logger then 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 most modern Linux systems, the sudo
is required, since the system logs are visible only to the system administration accounts.
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
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"
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 weewx
sysV sudo /etc/init.d/weewx stop
launchd sudo launchctl unload /Library/LaunchDaemons/com.weewx.weewxd.plist
-
Enable debug. Set
debug=1
in the configuration file (typicallyweewx.conf
). Settingdebug=2
will 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
tail
orjournalctl
to watch the system log, combined withtee
to 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/messages
sudo tail -f /var/log/messages | tee /tmp/mylog
Redhat, Fedora, CentOS, Rocky syslog /var/log/syslog
sudo tail -f /var/log/syslog | tee /tmp/mylog
Debian, Ubuntu, Raspian, MacOS journald sudo journalctl -u weewx -f | tee /tmp/mylog
Redhat, SUSE, Debian -
Start WeeWX and watch the log
In a different terminal, start
weewxd
as you watch the log output in the first terminal.init system how to start weewxd systemd sudo systemctl start weewx
sysV sudo /etc/init.d/weewx start
launchd 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.
[StdRESTful] WeatherCloud id = WEATHERCLOUD_ID key = WEATHERCLOUD_KEY