gunicorn配置文件为gunicorn_config.py里面有日志的配置

# errorlog = '/home/admin/output/erebus/logs/gunicorn_error.log'
# loglevel = 'info'
# loglevel = 'debug'
# accesslog = '/home/admin/output/erebus/logs/gunicorn_access.log'
# access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'

django如何捕获gunicorn的日志

注释掉上面的配置,则相关日志不输出,然后在django日志配置里添加

logconfig_dict = {
'version':1,
'disable_existing_loggers': False,
'loggers':{
"gunicorn.error": {
"level": "DEBUG",# 打日志的等级可以换的,下面的同理
"handlers": ["error_file"], # 对应下面的键
"propagate": 1,
"qualname": "gunicorn.error"
}, "gunicorn.access": {
"level": "DEBUG",
"handlers": ["access_file"],
"propagate": 0,
"qualname": "gunicorn.access"
}
},
'handlers':{
"error_file": {
"class": "logging.handlers.RotatingFileHandler",
"maxBytes": 1024*1024*1024,# 打日志的大小,我这种写法是1个G
"backupCount": 1,# 备份多少份,经过测试,最少也要写1,不然控制不住大小
"formatter": "generic",# 对应下面的键
# 'mode': 'w+',
"filename": "/你要放日志的路径/gunicorn.error.log"# 打日志的路径
},
"access_file": {
"class": "logging.handlers.RotatingFileHandler",
"maxBytes": 1024*1024*1024,
"backupCount": 1,
"formatter": "generic",
"filename": "/你要放日志的路径/gunicorn.access.log",
}
},
'formatters':{
"generic": {
"format": "'[%(process)d] [%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s'", # 打日志的格式
"datefmt": "[%Y-%m-%d %H:%M:%S %z]",# 时间显示方法
"class": "logging.Formatter"
},
"access": {
"format": "'[%(process)d] [%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s'",
"class": "logging.Formatter"
}
}
}

gunicorn的log如何传递给django,由django管理的更多相关文章

  1. celery的log如何传递给django,由django管理

    celery自己管理log目录 celery worker --autoscale=4,1 --app=erebus.celeryapp:app -l info -f /home/admin/outp ...

  2. django中将views.py中的python方法传递给html模板文件

    常规的模板渲染 from django.db import models # Create your models here. class ArticalType(models.Model): cap ...

  3. JavaWeb -- 服务器传递给Servlet的对象 -- ServletConfig, ServletContext,Request, Response

    1.  ServletConfig  有一些东西不合适在程序中写死,应该写在web.xml中,比如 文字怎么显示, 访问数据库名 和 密码, servlet要读取的配置文件 等等.. l在Servle ...

  4. 如何获取url中的参数并传递给iframe中的报表

    在使用报表软件时,用户系统左边一般有目录树,点击报表节点就会在右侧网页的iframe中显示出报表,同时点击的时候也会传递一些参数给网页,比如时间和用户信息等.如何使网页中的报表能够获取到传递过来的参数 ...

  5. AWK调用SHELL,并将变量传递给SHELL

    在Shell脚本中调用awk是非常自然和简单的,以前还写过一个关于awk/shell相互传递变量的文章:awk与shell之间的变量传递方法在awk脚本中,如果需要调用shell脚本/命令,则需要使用 ...

  6. Jmeter----A接口response中body的某一个参数传递给B接口request的body中使用(参数的传递)

    示例:将接口"获取待办列表"response中body的id值传递给接口"删除待办"request的body中使用: 操作步骤如下: 第一步:给"获取 ...

  7. 微软将把Windows Defender防火墙传递给 Linux 子系统

    前不久,微软以 Azure Sphere OS 的形式发布了自己的 Linux 版本.而在最新的开发中,该公司又决定将其 Windows Defender 防火墙的传递给 Linux 子系统(WSL) ...

  8. 详解~实现Runnable方法创建线程之为什么要将Runnable接口的子类对象传递给Thread的构造函数

    /** * @author zhao * @TIME 0419 22:56 End *定义线程的第二种方法:实现Runnable接口(不考虑安全问题) *步骤:1,定义一个子类实现Runnable接口 ...

  9. 通过BeanShell获取UUID并将参数传递给Jmeter

    有些HTTPS请求报文的报文体中包含由客户端生成的UUID,在用Jmeter做接口自动化测试的时候,因为越过了客户端,直接向服务器端发送报文,所以,需要在Jmeter中通过beanshell获取UUI ...

随机推荐

  1. 表单中submit和button按钮的区别!

    对于表单的按钮以前知道submit和button有区别,但没有深入探索,今天刚好又碰到这个问题,看了下网络上这位朋友已经有现成的总结了,而且比较到位,拿来跟大家分享下(原文地址:http://blog ...

  2. codeforces#571Div2 D---Vus the Cossack and Numbers【贪心】

    题目:http://codeforces.com/contest/1186/problem/D 题意:给定一个大小为$n$的浮点序列,这$n$个数的和为0. 现在对这个序列中的每个数,进行向上取整或向 ...

  3. TDOA基础之 delayed tx 实现说明

    不论是在TWR 还是TDOA定位算法中,delayed tx 都会用到,这篇博文主要解析delayed tx 实现. 何为delayed tx? delayed tx 是延时发送,为何要延时?因为这个 ...

  4. struts2--CRUD

    struts的CRUD 1.导入相关的pom依赖(struts.自定义标签库的依赖) <dependency> <groupId>jstl</groupId> &l ...

  5. IE下iframe不能正常加载,显示空白

    下午帮忙看了一个web问题,index.html中嵌入<iframe>来加载同文件目录下的一个页面,在多个浏览器下测试,发现IE浏览器中会出现问题,<iframe>不能正常加载 ...

  6. MongoDB 分片管理(二)查看网络连接

    1.1 查看连接统计 connPoolStats,查看mongos与mongod之间的连接信息,并可得知服务器 上打开的所有连接 1.2 限制连接数量

  7. 百度UEditor编辑器从word粘贴公式

    官网地址http://ueditor.baidu.com Git 地址 https://github.com/fex-team/ueditor 参考博客地址 http://blog.ncmem.com ...

  8. Linux操作系统常用命令合集——第六篇-软件包操作(2个命令)

    一.前言介绍 软件包即程序包 程序包管理 关键词:rpm程序包管理.YUM仓库管理.源码编译安装 程序包管理: 将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装. ...

  9. leetcode解题报告(20):Rotate Array

    描述 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the arr ...

  10. RESTFUL API 安全认证方式

    一般基于REST API 安全设计常用方式有: HTTP Basic Basic admin:admin Basic YWRtaW46YWRtaW4= Authorization: Basic YWR ...