any use case of logging.config.listen()?

Zhang Weiwu tristan at realss.com
Tue Dec 3 20:34:13 EST 2013


Why would anyone use it? I can't think of use cases when one need to change 
logging configuration dynamically through socket, but not needing the same 
flexibility on overall configuration for his application (configparser). It 
feels strange to design a socket interface only to expose logging 
configuration. If you use logging.config.listen, I very much wish to know 
what problem are you attacking.

I imagined this use case, and invite you to debate if it be valid. Thanks.

 	To design a GUI monitor of a daemon, like amule-gui (log-reading
 	monitor for amule) or pureadmin (log-reading monitor for pureftp).
 	Here is how:

 	1. The user starts the monitor on his PC. It socket-coneect the
 	daemon written in python - perhaps wrapped by SSH protection - and
 	send a new config file that adds SocketHandler with his own IP
 	address and port.

 	2. The daemon starts to emit log to TCP socket, the user watches his
 	monitor.

 	3. When the user finishes, the GUI monitor sends a new config file
 	to remove the handler (is it possible with current API?)  Or, the
 	user drops out, the server finds socket dead and removes the
 	SocketHandler on its own.

 	It works like FTP's PORT command, asking server to establish
 	connection back to the client. Unfortunately this technology doesn't
 	work nowadays when most PCs are behind NAT firewall.

It begets the question, that if it is easier to write a socket-listening 
loging handler and forget all about logging.config.listen() stuff. I never 
did it before, hence the question.



More information about the Python-list mailing list