Windows Azure Web Sites log streams will transfer information written to any text file in the D:/home/logfiles your website. Therefore, the requirement is that your application writes its log files to this directory. Support for streaming is quite common and can transfer any text file that is located in the LogFiles folder. But in order for it to work, the file must be readable, so if you open it exclusively, it will not work.
In Python, this can be a bit of a challenge, given that multiple instances of the application can run at the same time, so the problem of locking files can be a problem.
A workaround for this is to use ConcurrentLogHandler , which will allow simultaneous access to write to log files. This requires pywin32 (the Python extension for Windows), which is not installed by default on Windows Azure websites, so you will have to include this dependency with your application. Be sure to specify the appropriate version for the Python runtime used by Windows Azure websites (Python 2.7 32 bits at this time).
The DjangoWAWSLogging sample shows how to do this. See settings.py and views.py . As explained in the README project, at this time the log can only be downloaded when the website is stopped. This is probably due to the fact that in ConcurrentLogHandler the file is opened in exclusive mode. See this question .
This snippet from settings.py sets up the log handler using the LOGFILE environment variable as the file name:
'ConcurrentLogHandler':{ 'level': 'DEBUG', 'class': 'cloghandler.ConcurrentRotatingFileHandler', 'formatter': 'verbose', 'filename': os.getenv('LOGFILE', 'django.log') },
Since log streaming can process multiple files at the same time, this is probably the best strategy for each log of a website instance in a different file, for example:
'handlers': { 'logfile': { 'level':'DEBUG', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(os.getenv('LOGPATH', "."), str(uuid.uuid1()) + ".log"), 'maxBytes': 1024 * 1024, 'backupCount': 9, 'formatter': 'standard', }, },
Where LOGPATH is an environment variable configured on Windows Azure websites as "D: \ home \ logfiles".
This configuration in itself still does not solve the problem, perhaps because, according to the Python Documentation , under Windows, "logging opens files with exclusive locks."