I'm trying to use the %(here)s variable in my logging config but I get the
following error:
ConfigParser.InterpolationMissingOptionError: Bad value substitution:
section: [handler_file]
option : args
key : here
rawval : ('%(here)s/var/log/krumplez.local.log', 'midnight', 1, 3)
The corresponding section of my ini file is:
[handler_file]
class = handlers.TimedRotatingFileHandler
args = ('%(here)s/var/log/kurmplez.local.log', 'midnight', 1, 3)
level = NOTSET
formatter = generic
Google wasn't very helpful in figuring out how to configure logging output to a
directory relative to the config file. Is there some trick to getting the
interpolation to work? The comment at the top of the file says:
# The %(here)s variable will be replaced with the parent directory of this file
#
Thanks,
- kochhar
The file is used in two different ways. Variables are extracted using
paste.deploy.loadwsgi.NicerConfigParser, which interpolates %(here)s.
Logging configuration is done by logging.config.fileConfig, which
doesn't know about interpolation. You'll probably have to use
absolute paths. Or if you're running the application under
Supervisor, you can let it default to stdout and then redirect it to a
file in the Supervisor config.
--
Mike Orr <slugg...@gmail.com>
That's quite non-intuitive. What's the benefit of lumping the configs together
if they behave differently? Could NicerConfigParser be used to generate an
temporary interpolated version of the config file to give to logging's
fileConfig? I'd be happy to write a patch if that's a reasonable fix.
> You'll probably have to use
> absolute paths. Or if you're running the application under
> Supervisor, you can let it default to stdout and then redirect it to a
> file in the Supervisor config.
I'm using absolute paths now, it makes running the app from multiple locations
painful.
The 'benefit' is using Python's standard configuration mechanism. The
code is all in paste.deploy.loadwsgi or thereabouts, so you'd have to
file a bug there and convince Ian to include it.
One thing I wish it would do is to configure the logging when loading
the file standalone; e.g., in model tests. Currently it configures
logging only when you go through 'paster serve'.
--
Mike Orr <slugg...@gmail.com>
>
> Mike Orr wrote:
>> On Fri, Jul 31, 2009 at 12:05 PM, kochhar<kochh...@gmail.com>
>> wrote:
>>
>> The file is used in two different ways. Variables are extracted
>> using
>> paste.deploy.loadwsgi.NicerConfigParser, which interpolates %(here)s.
>> Logging configuration is done by logging.config.fileConfig, which
>> doesn't know about interpolation.
>
> That's quite non-intuitive. What's the benefit of lumping the
> configs together
> if they behave differently? Could NicerConfigParser be used to
> generate an
> temporary interpolated version of the config file to give to logging's
> fileConfig? I'd be happy to write a patch if that's a reasonable fix.
fileConfig accepts a set of defaults to pass to ConfigParser, so I've
made PasteScript's logging config loader pass 'here' (and also
'__file__' which PasteDeploy apparently sets up):
http://trac.pythonpaste.org/pythonpaste/changeset/8052
--
Philip Jenvey
How does that work? The defaults are supposed to be
logging.basicConfig arguments, not 'here' and '__file__', which
basicConfig doesn't know what to do with.
--
Mike Orr <slugg...@gmail.com>
No, they're just defaults for ConfigParser. basicConfig isn't involved
at all with fileConfig
--
Philip Jenvey
Thanks! Is a new release planned anytime soon? I could track trunk if it's going
to be a while.
- kochhar