Can't use TimedRotatingFileHandler as handler

2,531 views
Skip to first unread message

Jan Koprowski

unread,
Apr 21, 2009, 12:47:13 AM4/21/09
to pylons-discuss
Hi !

I'am trying set one extra logger in Pylons. My logger call
"actions". This should be a file timed routed (handler_access).


--------------------- development.ini ---------------------
[...]

# Logging configuration
[loggers]
keys = root, routes, zhradmin2, sqlalchemy, actions

[handlers]
keys = console, access

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_routes]
level = INFO
handlers =
qualname = routes.middleware
# "level = DEBUG" logs the route matched and routing variables.

[logger_zhradmin2]
level = DEBUG
handlers =
qualname = zhradmin2

[logger_sqlalchemy]
level = INFO
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)

[logger_actions]
level = INFO
handlers = access
qualname = action_recorder

[handler_access]
class = TimedRotatingFileHandler
args = ('logs/access.log', 'H', 24, 100)
level = NOTSET
formatter = generic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s %(message)s
datefmt = %d %m %Y %H:%M:%S
--------------------- end of file ---------------------

After i start paster i get following errors

--------------------- cut here ---------------------
Starting subprocess with file monitor
Traceback (most recent call last):
File "/usr/local/bin/paster", line 8, in <module>
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')
()
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/command.py", line 84, in run
invoke(command, command_name, options, args[1:])
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/command.py", line 123, in invoke
exit_code = runner.run(args)
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/command.py", line 218, in run
result = self.command()
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/serve.py", line 271, in command
self.logging_file_config(log_fn)
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/command.py", line 757, in logging_file_config
fileConfig(config_file)
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/util/logging_config.py", line 85, in fileConfig
handlers = _install_handlers(cp, formatters)
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/util/logging_config.py", line 155, in
_install_handlers
klass = _resolve(klass)
File "/usr/local/lib/python2.5/site-packages/PasteScript-1.7.3-
py2.5.egg/paste/script/util/logging_config.py", line 95, in _resolve
found = __import__(used)
ImportError: No module named TimedRotatingFileHandler
--------------------- cut here ---------------------

What's wrong ? Pylons 0.9.7

P.S.
I still can import this handler from python console:
from logging.handlers import TimedRotatingFileHandler

Greetings from Poland.
--
Jan Koprowski

John Dickson

unread,
Apr 21, 2009, 12:51:18 AM4/21/09
to pylons-...@googlegroups.com
Hi Jan

You need to include the package in the handler class:

    class = logging.handlers.TimedRotatingFileHandler

Cheers ....................... JD


2009/4/21 Jan Koprowski <Jan.Ko...@gmail.com>



--
  "I started with nothing, and I've still got most of it left"

Jan Koprowski

unread,
Apr 21, 2009, 1:04:59 AM4/21/09
to pylons-discuss


On Apr 21, 6:51 am, John Dickson <capts...@gmail.com> wrote:
> Hi Jan
>
> You need to include the package in the handler class:
>
>     class = logging.handlers.TimedRotatingFileHandler
>
> Cheers ....................... JD

Works grate ! Thank You ! I don't find this in Pylons/Python
documentation.
Reply all
Reply to author
Forward
0 new messages