Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django应登录gunicorn';s日志文件_Python_Django_Logging_Gunicorn - Fatal编程技术网

Python Django应登录gunicorn';s日志文件

Python Django应登录gunicorn';s日志文件,python,django,logging,gunicorn,Python,Django,Logging,Gunicorn,我有一个在服务器上运行的django应用程序。它从枪角开始。我想让django把它的日志输出放到gunicorn的日志文件中。但是当我查看文件时,没有django日志条目 我想当我在控制台上打印日志时,gunicorn会记录它 以下是gunicorn开头的代码片段: exec ../bin/gunicorn ${django_app_name}.wsgi:application \ -D \ -p $unicorn_pidfile \ -b uni

我有一个在服务器上运行的django应用程序。它从枪角开始。我想让django把它的日志输出放到gunicorn的日志文件中。但是当我查看文件时,没有django日志条目

我想当我在控制台上打印日志时,gunicorn会记录它

以下是gunicorn开头的代码片段:

exec ../bin/gunicorn ${django_app_name}.wsgi:application \
        -D \
        -p $unicorn_pidfile \
        -b unix:$unicorn_sockfile \
        --log-level debug \
        --log-file $unicorn_logfile \
        --error-logfile $unicorn_error_logfile \
       # --log-level debug \
       # --log-level debug --log-file $unicorn_logfile \
        #--log-level error --log-file $unicorn_error_logfile \
         -w $num_workers \
        --name $django_app_name > $unicorn_logfile
下面是我如何(尝试)登录django(settings.py):

只需删除脚本末尾的$unicorn\u日志文件。
--日志文件$unicorn\u logfile
足以进行日志记录。但是您正在通过
操作符覆盖现有日志

设置
--启用stdio继承
。谢谢您的回答。我添加了这一行,但没有任何更改我添加了你的行,但当我重新启动我的应用程序(使用gunicorn)时,它告诉我enable_stdio_继承为false(在日志文件中)。是虫子吗?
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'verbose': {
            'format': "[ThreadID: %(thread)d %(asctime)s.%(msecs)d] %(levelname)s: %(message)s",
            'datefmt': "%H:%M:%S"
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'propagate': True,
            'level': 'DEBUG',
        },
        'rest': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    }
}
exec ../bin/gunicorn ${django_app_name}.wsgi:application \
            -D \
            -p $unicorn_pidfile \
            -b unix:$unicorn_sockfile \
            --log-level debug \
            --log-file $unicorn_logfile \
            --error-logfile $unicorn_error_logfile \
           # --log-level debug \
           # --log-level debug --log-file $unicorn_logfile \
            #--log-level error --log-file $unicorn_error_logfile \
             -w $num_workers \
            --name $django_app_name