Roundup Tracker - Issues

Issue 2551017

classification
Error when configuring New -L (loghttpvialogger) option (on windows)
Type: crash Severity: normal
Components: Command-line interface Versions: 1.6
process
Status: new
:
: : matt109, rouilj
Priority: :

Created on 2018-12-31 13:51 by matt109, last changed 2019-11-06 02:38 by rouilj.

Messages
msg6311 Author: [hidden] (matt109) Date: 2018-12-31 13:51
Hi I am receiving an error when I am attempting to configure the new
logging with rotation. I have configured the settings as follows:

1) Added entry to config.ini: config = logs\logging.ini
2) Created the above file in my logs folder exactly as on the web page:
[loggers]
keys=roundup.http

[logger_roundup.http]
level=INFO
handlers=rotate_weblog
qualname=roundup.http
propagate=0

[handlers]
keys=rotate_weblog

[handler_rotate_weblog]
class=logging.handlers.RotatingFileHandler
args=('httpd.log','a', 512000, 2)
formatter=plain

[formatters]
keys=plain

[formatter_plain]
format=%(message)s

and am getting the following error on service startup. I am running on
windows.

The instance's SvcRun() method failed 
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\win32\lib\win32serviceutil.py",
line 839, in SvcRun
    self.SvcDoRun()
  File
"C:\Python27\lib\site-packages\roundup\scripts\roundup_server.py", line
769, in SvcDoRun
    self.server = config.get_server()
  File
"C:\Python27\lib\site-packages\roundup\scripts\roundup_server.py", line
664, in get_server
    for (name, home) in tracker_homes])
  File "C:\Python27\lib\site-packages\roundup\instance.py", line 327, in
open
    return Tracker(tracker_home, optimize=optimize)
  File "C:\Python27\lib\site-packages\roundup\instance.py", line 57, in
__init__
    self.config = configuration.CoreConfig(tracker_home)
  File "C:\Python27\lib\site-packages\roundup\configuration.py", line
1571, in __init__
    Config.__init__(self, home_dir, layout=SETTINGS, settings=settings)
  File "C:\Python27\lib\site-packages\roundup\configuration.py", line
1178, in __init__
    self.load(config_path)
  File "C:\Python27\lib\site-packages\roundup\configuration.py", line
1635, in load
    self.init_logging()
  File "C:\Python27\lib\site-packages\roundup\configuration.py", line
1609, in init_logging
    logging.config.fileConfig(_file)
  File "C:\Python27\lib\logging\config.py", line 86, in fileConfig
    _install_loggers(cp, handlers, disable_existing_loggers)
  File "C:\Python27\lib\logging\config.py", line 190, in _install_loggers
    llist.remove("root")
ValueError: list.remove(x): x not in list 
%2: %3

If i comment out the line in the config.ini config = logs\logging.ini
then the service starts successfully.
msg6312 Author: [hidden] (rouilj) Date: 2018-12-31 19:43
Hi Matt:

In message
<1546264300.26.0.619166655035.issue2551017@roundup.psfhosted.org>,
Matt writes:
>New submission from Matt:
>Hi I am receiving an error when I am attempting to configure the new
>logging with rotation.

Have you tried with logging.ini configured but no -L on the command
line?  I.E. same config as #1 and #2 below but no -L on the command
line.

>I have configured the settings as follows:
>
>1) Added entry to config.ini: config = logs\logging.ini
>2) Created the above file in my logs folder exactly as on the web page:
> [...]
>and am getting the following error on service startup. I am running on
>windows.
>
>The instance's SvcRun() method failed 
>Traceback (most recent call last):
>  File "C:\Python27\lib\site-packages\win32\lib\win32serviceutil.py",
>line 839, in SvcRun
>    self.SvcDoRun()
>  File
> [...]
>  File "C:\Python27\lib\site-packages\roundup\configuration.py", line
>1609, in init_logging
>    logging.config.fileConfig(_file)
>  File "C:\Python27\lib\logging\config.py", line 86, in fileConfig
>    _install_loggers(cp, handlers, disable_existing_loggers)
>  File "C:\Python27\lib\logging\config.py", line 190, in _install_loggers
>    llist.remove("root")
>ValueError: list.remove(x): x not in list 
>%2: %3
>
>If i comment out the line in the config.ini config = logs\logging.ini
>then the service starts successfully.

If it works without -L but with logging.ini configured, let me know
bwcuse what I suggest below is unlikley to work.

If it fails without -L, use the example below as your logging.ini.

====
[loggers]
keys=root,roundup,roundup.http

[logger_root]
#DEBUG, INFO, WARNING, ERROR, CRITICAL
#also for root only NOTSET (all)
level=DEBUG
handlers=basic

[logger_roundup]
#DEBUG, INFO, WARNING, ERROR, CRITICAL
#also for root only NOTSET (all)
level=DEBUG
handlers=basic
qualname=roundup
propagate=0

[logger_roundup.http]
level=INFO
handlers=rotate_weblog
qualname=roundup.http
propagate=0

[handlers]
keys=basic,rotate_weblog

[handler_rotate_weblog]
class=logging.handlers.RotatingFileHandler
args=('httpd.log','a', 512000, 2)
formatter=plain

[handler_basic]
class=StreamHandler
args=(sys.stderr,)
formatter=plain

[formatters]
keys=plain

[formatter_plain]
format=%(message)s
====

(Note I am writing this from memory, so it may need a little work.)

This adds root and roundup logger. Since the traceback includes
'llist.remove("root")', supplying a root logger may fix it. Also since
you are using roundup.http I wonder if a roundup logger is required as
well to complete the heirarchy.

Try running roundup by hand from a cmd window (not as a service) and
see if it the modified logging.ini works. If it does, we probably need
to change the basic handler to log to a rotating file or something
rather than stderr.

Let me know how this works.
msg6321 Author: [hidden] (matt109) Date: 2019-01-28 10:49
Hi John

Sorry it has took me a while to reply...

Adding the root section and associated handler directives, you
suggested,  allowed the service to start without error and the
information continues to get logged to my roundup.log.

However, there does not seem to be a roundup.http log?

Although my main driver for this configuration change was to allow the
roundup.log to  be rotated...

If i can be of any help with trying more settings out, please let me know.

Thanks for your help.

Matt....
msg6794 Author: [hidden] (rouilj) Date: 2019-11-03 23:07
Hi Matt:

I let this drop off my radar. Sorry about that.

I just ran:

  python3 roundup/scripts/roundup_server.py -n 0.0.0.0 -p 9017 -L 
demo=demo

on a linux box with the logging.ini in this ticket and I have an 
http.log file with:

172.25.1.34 - - [03/Nov/2019 18:02:15] "GET /demo HTTP/1.1" 301 -
172.25.1.34 - - [03/Nov/2019 23:02:16] "GET /demo/ HTTP/1.1" 500 -
172.25.1.34 - - [03/Nov/2019 18:02:17] "GET /favicon.ico HTTP/1.1" 200 
-

so I'm not quite sure what is happening for you.

I'll see if I can scrounge up a windows server system. What windows 
version are you running?

-- rouilj
msg6795 Author: [hidden] (rouilj) Date: 2019-11-03 23:26
Actually I may have an idea. Change:

[handler_basic]
class=StreamHandler
args=(sys.stderr,)
formatter=plain

to

[handler_basic]
class=logging.handlers.RotatingFileHandler
args=('demo.log', 'a', 512000, 2)
formatter=plain

I'll bet running as a service requires that nothing to to 
stdout/stderr.

Also you probably want to drop:

[logger_roundup]
#DEBUG, INFO, WARNING, ERROR, CRITICAL
#also for root only NOTSET (all)
level=DEBUG
handlers=basic
qualname=roundup
propagate=0

to

[logger_roundup]
#DEBUG, INFO, WARNING, ERROR, CRITICAL
#also for root only NOTSET (all)
level=WARNING
handlers=basic
qualname=roundup
propagate=0

for production otherwise demo.log will be quite chatty.
History
Date User Action Args
2019-11-06 02:38:52rouiljsettitle: Error when configuring New -L (loghttpvialogger) option -> Error when configuring New -L (loghttpvialogger) option (on windows)
2019-11-03 23:26:04rouiljsetmessages: + msg6795
2019-11-03 23:07:11rouiljsetmessages: + msg6794
2019-06-16 01:54:20rouiljsettype: crash
2019-01-28 10:49:51matt109setmessages: + msg6321
2018-12-31 19:43:34rouiljsetnosy: + rouilj
messages: + msg6312
2018-12-31 13:51:40matt109create