[Twisted-Python] Log level using Twistd
![](https://secure.gravatar.com/avatar/f8f677d2910560da1f4a830e3c99b09d.jpg?s=120&d=mm&r=g)
Hello, I am trying to modify loglevel withou result. I configure my app logging inside the tac file as: logging.basicConfig(level=logging.ERROR, format="%(asctime)s --- %(name)s - %(levelname)s - %(message)s") logfile = DailyLogFile("gdumper.log", "/var/log") application.setComponent(ILogObserver, FileLogObserver(logfile).emit) 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
![](https://secure.gravatar.com/avatar/607cfd4a5b41fe6c886c978128b9c03e.jpg?s=120&d=mm&r=g)
On 08:57 am, juanito1982@gmail.com wrote:
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:
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
![](https://secure.gravatar.com/avatar/607cfd4a5b41fe6c886c978128b9c03e.jpg?s=120&d=mm&r=g)
On 08:57 am, juanito1982@gmail.com wrote:
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:
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
participants (2)
-
exarkun@twistedmatrix.com
-
Juan Antonio Ibañez Santorum