[Twisted-Python] Log level using Twistd
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Wed Apr 30 05:55:23 MDT 2014
On 08:57 am, juanito1982 at gmail.com wrote:
>Hello,
>
> I am trying to modify loglevel withou result. I configure my app
>logging
>inside the tac file as:
You omitted the imports necessary to interpret the example code with
certainty but I'll make some guesses. Next time post a complete, self-
contained example.
This line:
>
>logging.basicConfig(level=logging.ERROR, format="%(asctime)s ---
>%(name)s -
>%(levelname)s - %(message)s")
configures the standard library logging module.
This line:
>
>logfile = DailyLogFile("gdumper.log", "/var/log")
creates a log writer from the Twisted logging system that will write to
a file.
And this line:
>
>application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
makes `twistd` configure Twisted's logging system with a log observer
that will use that log writer to record log events.
Twisted's logging system and the standard library logging system are
separate things, though. Configuring the standard library logging
system will not make any difference to Twisted's logging system.
If you want log messages emitted by `log.msg` and `log.err` to traverse
the standard library logging system then the minimum you need to do is
use `twisted.python.log.PythonLoggingObserver` instead of
`FileLogObserver`.
`PythonLoggingObserver` observes log events in the Twisted logging
system and sends them to the standard library logging system.
Once you do that you may be able to configure the standard library
logging system to behave as you desire.
Jean-Paul
>logging.basicConfig call seems do not apply as I get both log.msg and
>log.err messages into the log. Is there any other way to set up log
>level?
>
>Regards
More information about the Twisted-Python
mailing list