6

I have some prints on my application for debug purpose. On the production server where these printed information goes? on apache log? I am using apache/mod_wsgi .

Thanks.

Serjik
  • 10,543
  • 8
  • 61
  • 70
icn
  • 17,126
  • 39
  • 105
  • 141

2 Answers2

25

use logging

I like to log to file at times so I use the following in my settings.py

import logging


logging.basicConfig(
    level = logging.INFO,
    format = '%(asctime)s %(levelname)s %(message)s',
    filename = '/tmp/djangoLog.log',)

and where I want logging:

import logging

logging.info("Making the alpha-ldap connection")

then in /tmp/djangoLog.log I would see the line "Making the alpha-ldap connection"e

Isopycnal Oscillation
  • 3,234
  • 6
  • 21
  • 37
grantk
  • 3,958
  • 4
  • 28
  • 37
2

Check this thread for some pointers: In Django, how do I allow print statements to work with Apache WSGI?

That said, you shouldn't use print statements for debugging on your production system, especially as django comes with a nice, flexible logging module included nowadays.

Community
  • 1
  • 1
arie
  • 18,737
  • 5
  • 70
  • 76
  • I forget what component it is but I know when I upgraded to Django 1.3 I had to remove all print statements. – grantk Apr 13 '11 at 18:25