Noisy logging, log_success = False not followed

84 views
Skip to first unread message

Chris Nelson

unread,
May 15, 2020, 12:53:26 AM5/15/20
to weewx-user

These two log.info lines in manager.py do not use the config file log_success switch, resulting in entries every five minutes.  Adding the log_success switch test within _addSingleRecord instances is not trivial since the config is not passed to the object.

 

May 12 18:55:15 shop2 journal: weewx[7760] INFO weewx.manager: Added record 2020-05-12 18:55:00 MST (1589334900) to database 'weewx.sdb'

May 12 18:55:15 shop2 journal: weewx[7760] INFO weewx.manager: Added record 2020-05-12 18:55:00 MST (1589334900) to daily summary in 'weewx.sdb'


This was noted back in 2017 also by Daniel Jönsson in this thread - not a new issue.  I just commented out the two calls to log.info().  I'm just working to clean up noise in my system log.

Tom Keffer

unread,
May 15, 2020, 7:55:31 AM5/15/20
to weewx-user
Version 4.0 allows much more control over what gets logged. To suppress everything below log level WARN, put this at the bottom of weewx.conf:

[Logging]
  [[loggers]]
    [[[weewx.manager]]]
      level = WARN

-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/11778f1a-f56b-4753-97e9-4bc53c9a03e3%40googlegroups.com.

Chris Nelson

unread,
May 15, 2020, 11:19:39 AM5/15/20
to weewx-user
Thanks Tom,
I re-read your logged page in detail after I posted this issue.  A couple of suggestions for the not fully initiated:

  • This link points to the Python logger documentation, whereas I thought I'd be reading about the WeeWX logging config schema
First, read, or, at least, attempt to read, the section on the schema of the configuration dictionary that logging uses.

  •  Perhaps add a commented out example [Logging] section to the weewx.conf.dist.

Unrelated, I thought that wunderfixer is no longer functional based on API changes at WU.  If correct then there is still a remnant in weewx.conf.dist:
        # If you plan on using wunderfixer, set the following
        # to your API key:
        api_key = replace_me

Thank you for continuing this project and bringing it up to Py3!
cjn


On Friday, May 15, 2020 at 4:55:31 AM UTC-7, Tom Keffer wrote:
Version 4.0 allows much more control over what gets logged. To suppress everything below log level WARN, put this at the bottom of weewx.conf:

[Logging]
  [[loggers]]
    [[[weewx.manager]]]
      level = WARN

-tk

On Thu, May 14, 2020 at 9:53 PM Chris Nelson <cjnc...@gmail.com> wrote:

These two log.info lines in manager.py do not use the config file log_success switch, resulting in entries every five minutes.  Adding the log_success switch test within _addSingleRecord instances is not trivial since the config is not passed to the object.

 

May 12 18:55:15 shop2 journal: weewx[7760] INFO weewx.manager: Added record 2020-05-12 18:55:00 MST (1589334900) to database 'weewx.sdb'

May 12 18:55:15 shop2 journal: weewx[7760] INFO weewx.manager: Added record 2020-05-12 18:55:00 MST (1589334900) to daily summary in 'weewx.sdb'


This was noted back in 2017 also by Daniel Jönsson in this thread - not a new issue.  I just commented out the two calls to log.info().  I'm just working to clean up noise in my system log.

--
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...@googlegroups.com.

nine...@gmail.com

unread,
May 15, 2020, 3:34:06 PM5/15/20
to weewx...@googlegroups.com

I tried to follow the instructions in the v4 logging wiki, https://github.com/weewx/weewx/wiki/WeeWX-v4-and-logging.  I added this to my weewx.conf file:

 

[Logging]

    [[loggers]]

        # Root logger

        [[[root]]]

          handlers = rotate,                # 1

    [[handlers]]

        # Log to a set of rotating files   

        [[[rotate]]]

            level = DEBUG                   # 2

            formatter = standard            # 3

            class = logging.handlers.RotatingFileHandler  # 4

            filename = /var/log/weewx.log   # 5

            maxBytes = 10000000             # 6

            backupCount = 4                 # 7

 

Nothing is being logged to the weewx.log file and weewx is not updating the archive file or reports.  It appears weewx has crashed but syslog is not showing anything which I’m assuming indicates the program is trying to write to the weewx.log file but cannot hence it isn’t recording any error messages.

 

I tried top add syslog to the handlers thinking something might show up in syslog.

 

handlers = rotate, syslog              

 

This is what I get in the syslog file:

 

May 15 14:20:21 raspberrypi systemd[1]: Starting LSB: weewx weather system...

May 15 14:20:21 raspberrypi weewx[2183] INFO __main__: Initializing weewx version 4.0.0

May 15 14:20:21 raspberrypi weewx[2183] INFO __main__: Using Python 3.7.3 (default, Dec 20 2019, 18:57:59) #012[GCC 8.3.0]

May 15 14:20:21 raspberrypi weewx[2183] INFO __main__: Platform Linux-4.19.97-v7+-armv7l-with-debian-10.4

May 15 14:20:21 raspberrypi weewx[2183] INFO __main__: Locale is 'en_US.UTF-8'

May 15 14:20:21 raspberrypi weewx[2183] INFO __main__: PID file is /var/run/weewx.pid

 

This is a new install.  Everything works fine until I try to add [Logging} to the weewx.conf file.

 

Tom

Chris Nelson

unread,
May 15, 2020, 6:58:51 PM5/15/20
to weewx-user
Thinking out loud here... Running as the Pi user? Have write access to /var/log?

Tom Keffer

unread,
May 15, 2020, 8:09:41 PM5/15/20
to weewx-user
Sorry, Tom. This is due to a bug in how weewx configures the logger. The problem is that weewx does not convert strings to int when configuring.  It was fixed a couple weeks ago (commit 6348741), but I totally forgot about it.

You have two choices: 
  1. Replace your copy of weeutil/logger.py with the one in the repository, or 
  2. remove the integers from the configuration stanza. It becomes
[Logging]
    [[loggers]]
        # Root logger
        [[[root]]]
          handlers = rotate,                # 1
    [[handlers]]
        # Log to a set of rotating files  
        [[[rotate]]]
            level = DEBUG                   # 2
            formatter = standard            # 3
            class = logging.handlers.RotatingFileHandler  # 4
            filename = /var/log/weewx.log   # 5

-tk

On Fri, May 15, 2020 at 3:58 PM Chris Nelson <cjnc...@gmail.com> wrote:
Thinking out loud here...  Running as the Pi user?  Have write access to /var/log?

--
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.

nine...@gmail.com

unread,
May 15, 2020, 9:09:36 PM5/15/20
to weewx...@googlegroups.com

Thanks Tom.  I updated the logger.py file and all is well.  I also changed the formatter to verbose so I could get date/time stamps.

 

Tom

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of Tom Keffer
Sent: Friday, May 15, 2020 7:09 PM
To: weewx-user <weewx...@googlegroups.com>
Subject: Re: [weewx-user] Noisy logging, log_success = False not followed

 

Sorry, Tom. This is due to a bug in how weewx configures the logger. The problem is that weewx does not convert strings to int when configuring.  It was fixed a couple weeks ago (commit 6348741), but I totally forgot about it.

 

You have two choices: 

1.   Replace your copy of weeutil/logger.py with the one in the repository, or 

2.   remove the integers from the configuration stanza. It becomes

[Logging]
    [[loggers]]
        # Root logger
        [[[root]]]
          handlers = rotate,                # 1
    [[handlers]]
        # Log to a set of rotating files  
        [[[rotate]]]
            level = DEBUG                   # 2
            formatter = standard            # 3
            class = logging.handlers.RotatingFileHandler  # 4
            filename = /var/log/weewx.log   # 5

-tk

 

On Fri, May 15, 2020 at 3:58 PM Chris Nelson <cjnc...@gmail.com> wrote:

Thinking out loud here...  Running as the Pi user?  Have write access to /var/log?

--
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/8fb4e590-c1f8-4220-beef-ab6e6baba964%40googlegroups.com.

--
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.

nine...@gmail.com

unread,
May 25, 2020, 6:55:57 PM5/25/20
to weewx...@googlegroups.com

Following these instructions I had logging to weewx.log working.  I upgraded to 4.1.0 and am now logging to syslog and not weewx.log.  I tied Logging with and without the integers in my config file as below.

 

#[Logging]

#    [[loggers]]

#        # Root logger

#        [[[root]]]

#            handlers = rotate,   

#    [[handlers]]

#        # Log to a set of rotating files   

#        [[[rotate]]]

#            level = DEBUG  

#            formatter = verbose   

#            class = logging.handlers.RotatingFileHandler  

#            filename = /var/log/weewx.log   

#            maxBytes = 10000000   

#            backupCount = 4          

 

[Logging]

    [[loggers]]

        # Root logger

        [[[root]]]

            handlers = rotate,   

    [[handlers]]

        # Log to a set of rotating files   

        [[[rotate]]]

            level = DEBUG  

            formatter = verbose   

            class = logging.handlers.RotatingFileHandler  

            filename = /var/log/weewx.log

 

Tom

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of Tom Keffer
Sent: Friday, May 15, 2020 7:09 PM
To: weewx-user <weewx...@googlegroups.com>
Subject: Re: [weewx-user] Noisy logging, log_success = False not followed

 

Sorry, Tom. This is due to a bug in how weewx configures the logger. The problem is that weewx does not convert strings to int when configuring.  It was fixed a couple weeks ago (commit 6348741), but I totally forgot about it.

 

You have two choices: 

1.   Replace your copy of weeutil/logger.py with the one in the repository, or 

2.   remove the integers from the configuration stanza. It becomes

[Logging]
    [[loggers]]
        # Root logger
        [[[root]]]
          handlers = rotate,                # 1
    [[handlers]]
        # Log to a set of rotating files  
        [[[rotate]]]
            level = DEBUG                   # 2
            formatter = standard            # 3
            class = logging.handlers.RotatingFileHandler  # 4
            filename = /var/log/weewx.log   # 5

-tk

 

On Fri, May 15, 2020 at 3:58 PM Chris Nelson <cjnc...@gmail.com> wrote:

Thinking out loud here...  Running as the Pi user?  Have write access to /var/log?

--
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/8fb4e590-c1f8-4220-beef-ab6e6baba964%40googlegroups.com.

--
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.

Tom Keffer

unread,
May 25, 2020, 7:13:21 PM5/25/20
to weewx-user

My apologies. The layout of the configuration dictionary changed, and I have not had a chance to update the Wiki. The change makes it more consistent with the Python docs. You want:

[Logging]
        # Root logger
    [[root]]
       handlers = rotate,  
    [[loggers]]

    [[handlers]]
        # Log to a set of rotating files  
        [[[rotate]]]
            level = DEBUG  
            formatter = verbose  
            class = logging.handlers.RotatingFileHandler  
            filename = /var/log/weewx.log

The difference is that the root logger, [[root]], is now a peer, instead of a child, of [[loggers]].

V4.1.0 can now handle the integer options maxBytes and backupCount, if you want to put them back in.

-tk



nine...@gmail.com

unread,
May 25, 2020, 7:32:04 PM5/25/20
to weewx...@googlegroups.com

Thanks Tom.  Working fine now.

Reply all
Reply to author
Forward
0 new messages