"Graham Dumpleton" <[EMAIL PROTECTED]> writes:

> Nic wrote:
>> Programmers may or may not want to redirect logging through Apache. If
>> mod_python used the system you describe there would either have to be:
>>
>> 1. config syntax to allow module 'logging' glue to be turned off
>> 
>> 2. removal of the apache log handler in all code that didn't want it
>> 
>> I don't like either of those.
>> 
>> I can think of lots and lots of reasons why code using logging
>> wouldn't want to log to Apache.
>
> I attached the log handler to the "mod_python" logger. Thus you have
> to select that logger explicitly for it to be redirected to Apache. If a user
> wants other loggers to redirect to Apache, within a PythonImport module
> they could grab the global log handler instance from where it is kept
> and add it against other loggers as they see fit. They could still also
> create their own instance of the Apache log handler as well, as the
> request cache isn't within the instance anyway and so doesn't matter
> if there is more than one.
>
> Thus, use of logging to Apache is optional.

I don't believe this is as useful.

One major benefit of logging is that it is hierarchial. The reason
that I wanted the glue in the first place is that I have app code that
I want to interface to the web. The app code uses logging so it's
natural to try to make the logging go through Apache.

But I wouldn't want to have to change all my loggers to use the new
handler... that would be significant effort.

Your system *is* useful for more casual logging in the mod_python
context, say in an add-on handler framework.

But such frameworks could take the time to do their own logging
integration in whatever way makes sense for them.



>> > Apart from the benefit of individual request handlers not having to create
>> > log handler instances and all the cleanup problems with that etc, 
>> 
>> I don't believe it is onerous to have to specifically attach the
>> Apache log handling glue in the handler.
>
> I would suggest though that rather than add such code to every single
> handler, use a separate PythonHandler phase to do the work. That way
> it is in one spot only at least.

Seems reasonable when you have lots and lots of entry points.


>> Another advantage of your system is that the logging config file
>> syntax could be used to assign loggers (I think).
>
> I'm not too knowledgeable on the logging module, perhaps you could
> explain that one further. Would it simply be a case of somehow pointing
> at mod_python.apache.ApacheLogHandler and it would create an instance
> automatically??

Yes. You could say in a logging config file:

     [loggers]
     keys=mod_python,my_handler1,my_handler2,my_handler3

     [handlers]
     keys=mod_python_logging_handler

     [logger_my_handler1]
     level=DEBUG
     handlers=mod_python_logging_handler

I don't know how widespread logging config files are in the Python
world. They are *very* mandated in Java logging but Python logging
seems to me not to need them at all (I've not used one in anger yet).


Nic

Reply via email to