Benedict Verheyen schreef:
> Jeremy Dunck schreef:
>>> Or i should be doing this in the settings file and importing this in my
>>> files. But then again, i use utility classes and then those would have
>>> to import settings to be able to use the same logfile. That doesn't feel
>>> right.
>> After you've done this setup code in settings.py, this is all you need
>> in the other files:
>>
>> import logging
>> logger = logging.getLogger('stats')
>> logger.error('hi there')
>>
>> ====
>>
>> The logging module keeps a registry of loggers and associated
>> handlers; calling getLogger gets a reference to logger you already
>> configured with the handlers in settings.py.
>
> Hi Jeremy,
>
> indeed that's a way to do it and i have done it like this but i've
> encountered something strange. Maybe something with mod_python?
>
> Anyway, i'm setting the logger up in the settings.py file and
> afterwards, in other files I import it like you showed.
> For instance, i'm trying to add logging to a module that gets data via
> odbc and sometimes the connection seems to be interrupted.
>
> The odbc code is placed in a seperate module & package.
> I add the import statement for the logger to the module. The "hi there"
> statement is printed once as expected but the log statements that are in
> the code (functions) that is run, are not printed to the log file.
> I know the code is run but the log statements have no effect?
>
> Weird thing is that it works in the custom manipulators code that i use.
>
> I tried defining a new logger in the odbc module and using that logger
> to print but that didn't seem to work. Again, only the "hi there
> statement is run" and the rest of the logging statements is ignored.
>
> Any idea as to why that is?
>
> Thanks,
> Benedict
*sigh* stupid! I cleaned up the import and other stuff from testing and
it now works. There was also an error in one of my log statements.
The only thing that is still weird is that every message ends up *twice*
in the log file. So per statement, 2 end up in the logfile ?!
Anyone seen this?
Benedict
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---