Search code examples
pythondjangogoogle-app-engineapp-engine-patch

django logging: log is not created


I'm running my app on the GAE development server, with app-engine-patch to run Django. One of my views is bugged , so I want to log everything that happens.

I added in myapp.views:

import logging
LOG_FILENAME = '/mylog.txt'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

and my function is:

def function(string):
    logging.debug('new call')
    #do stuff
    #logging.debug('log stuff')

My problem is that I can't find the log. When I run my app I get no errors, but the log is not created. I also tried various paths: /mylog.txt ,mylog.txt , c:\mylog.txt, c:\complete\path\to \my\app\mylog.txt, but it doesn't work.

On the other hand I tried to create and run a separate test: #test.py import logging

LOG_FILENAME = '/mylog.txt'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

logging.debug('test')

And the log is created without problems: c:\mylog.txt

I'm not familiar with logging so I don't know if there might be some issues with django, or appengine.

Thanks


Solution

  • You can't write to files on App Engine - thus, any attempt to log to text files is also doomed to failure. Log output will appear on the SDK console in development, or in the logs console in production.