django print information on production server

前端 未结 2 659
误落风尘
误落风尘 2021-01-01 01:13

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 .

Th

2条回答
  •  鱼传尺愫
    2021-01-01 02:15

    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

提交回复
热议问题