views:

58

answers:

3

Hello,

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

A: 

I am guessing the problem is that you put your log configuration in a view. A general rule of thumb for django logging is to set the log configuration in your settings.py.

Tao
+2  A: 

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.

Nick Johnson
A: 

By default, dev_appserver suppresses the debug log. To turn it on, run it with the --debug option. Note that dev_appserver itself uses the same logger, and will spew lots of debugging stuff you might not care about.

Your logging will print to stderr.

Wooble