I have deployed my django site on Apache and there's a problem which did not occur on my development machine, so I want to print some variables out to see what is happening.
I tried to use python logging module, where I did this:
import os, logging
FILE = os.getcwd()
logging.basicConfig(filename=os.path.join(FILE,'log.txt'),level=logging.DEBUG)
logging.debug('Write')
On my development machine there could be a log.txt showing up in the root directory in my django project. However when I did the same thing, there is not log.txt file showing up in the corresponding directory on my server.
Does anyone know how to debug it? Thanks!
You're assuming the current working directory is the Django project, but that's unlikely to be the case unless you specifically changed it in the wsgi file.
However, you should not be logging to a separate file. The default logging setup will log either to Apache's own log in /var/log or in a site-specific one in a subdirectory of that. Remove your extra configuration and let Django log there.