<<< macOS WeeWX Guides >>>
Managing the Log File
You will probably find that the log file starts to fill up at an alarming rate, to solve this we need to add some entries to the log rotation program:
First you need to create a new file in the /etc/newsyslog.d area as shown below.
$ sudo vi /etc/newsyslog.d/weewx.conf # logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] /Library/Logs/weewx.log 644 5 * $D0 /Library/Logs/weewx_error.log 644 5 * $W0
The values used are as follows
- logfilename
- This is the name of the file to be managed
- [owner:group]
- Optional field that allows the log file owner to be specified
- mode
- attributes of the file, in this case owner read/write and everyone else read only
- Count
- How many copies to keep, in addition to the current one, 6 is a weeks worth.
- size
- Allows for rotation based on file size, * ignores this value
- when
- $D0 is every day at midnight
- $W0 is every Sunday at midnight
- flags
- This is where you typically put the flags that ontrol compression
- I have deliberately not included any compression flags as there is a very high likelyhood that the rotation process will start whilst the log file is still being written to and if you start compressing the previous log file whilst it is being written to, you risk losing data still sitting in the buffer.
The new file is automatically loaded every time you run newsyslog and can be checked with the same command as shown below
$ sudo newsyslog $ sudo newsyslog -vv /Library/Logs/named.log 5J: --> will trim at Tue Dec 30 00:00:00 2014 /Library/Logs/weewx.log 6: --> will trim at Tue Dec 30 00:00:00 2014 /Library/Logs/weewx_error.log 6: --> will trim at Sun Jan 4 00:00:00 2015