The default logging configuration includes a syslog handler. While you're
trying to override that with a weewx.conf spec, the override gets *merged* into
the default configuration. So, the syslog handler never goes away.

Unfortunately, the way the Python handlers work, all specified handlers get
instantiated whether or not they will actually get used. No just-in-time
creation here. So the mere presence of the syslog handler could be causing
the problem. Or, maybe not.

A possible workaround. Put this in user/extensions.py. It basically removes
completely the specification of a syslog handler from the default handler.

import weeutil.logger

weeutil.logger.LOGGING_STR = """[Logging]
    version = 1
    disable_existing_loggers = True

    [[loggers]]
        # Root logger
        [[[root]]]
          level = {log_level}
          propagate = 1
          handlers = console,

    # Definitions of possible logging destinations
    [[handlers]]

        # Log to console
        [[[console]]]
            level = DEBUG
            formatter = verbose
            class = logging.StreamHandler
            # Alternate choice is 'ext://sys.stderr'
            stream = ext://sys.stdout

    # How to format log messages
    [[formatters]]
        [[[simple]]]
            format = "%(levelname)s %(message)s"
        [[[standard]]]
            format = "{process_name}[%(process)d] %(levelname)s %(name)s:
%(message)s"
        [[[verbose]]]
            format = "%(asctime)s  {process_name}[%(process)d]
%(levelname)s %(name)s: %(message)s"
            # Format to use for dates and times:
            datefmt = %Y-%m-%d %H:%M:%S
"""

See if that helps.

As for disable_existing_loggers, its exact function isn't very clear from
the documentation, at least to me, but it seems like in this case you want
it True.

-tk


On Sun, May 17, 2020 at 1:13 PM Vince Skahan <[email protected]> wrote:

> On Sunday, May 17, 2020 at 12:01:15 PM UTC-7, Tom Keffer wrote:
>>
>> The default handler is SysLogHandler
>> <https://docs.python.org/3/library/logging.handlers.html#sysloghandler>,
>> which uses a socket to communicate with syslogd, but there are lots of
>> other handlers.
>>
>> How about RotatingFileHandler
>> <https://docs.python.org/3/library/logging.handlers.html#rotatingfilehandler>?
>> Instructions are in the WeeWX wiki
>> <https://github.com/weewx/weewx/wiki/WeeWX-v4-and-logging#logging-to-rotating-files>.
>> NB: there is a bug in the WeeWX logging facility that prevents this handler
>> from working if you specify options maxBytes and backupCount. If you
>> want to use RotatingFileHandler, either avoid these two options, or use
>> the patched weeutil.logger
>> <https://raw.githubusercontent.com/weewx/weewx/master/bin/weeutil/logger.py>
>>  module.
>>
>>>
>>>
> No difference.  I grabbed the patched module from your link.  Still all
> kinds of barfing about syslog sockets no matter what I do.
>
> Does 'disable_existing_loggers' work ?  I can't see any difference in
> effect regardless of True/False or unspecified.
> What I'm looking is to disable all loggers that are built-in, and log only
> to the console (for a container this makes most sense to me).
>
> Here's the weewx.conf settings I'm failing with currently...
>
>
> [Logging]
>     version = 1
>     disable_existing_loggers = True
>
>     [[loggers]]
>         [[[root]]]
>            # the trailing comma here seems required
>
>            handlers = console,
>
>     [[handlers]]
>         [[[console]]]
>           level = DEBUG
>           formatter = verbose
>           class = logging.StreamHandler
>           # Alternate choice is 'ext://sys.stderr'
>           stream = ext://sys.stdout
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-development/2e9d6f6b-9324-46b3-815b-f4dbde3f7df7%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/2e9d6f6b-9324-46b3-815b-f4dbde3f7df7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/CAPq0zEDCvaJp-oC_b1SpRGQO9TPbOqEokt2X-rw8SrJHfGL7tg%40mail.gmail.com.

Reply via email to