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. for循环中使用async/await

    async function printFiles () { const files = await getFilePaths(); await Promise.all(files.map(async ...

  2. [HDU 5608]Function(莫比乌斯反演 + 杜教筛)

    题目描述 有N2−3N+2=∑d∣Nf(d)N^2-3N+2=\sum_{d|N} f(d)N2−3N+2=∑d∣N​f(d) 求∑i=1Nf(i)\sum_{i=1}^{N} f(i)∑i=1N​f ...

  3. LeetCode 269. Alien Dictionary

    原题链接在这里:https://leetcode.com/problems/alien-dictionary/ 题目: There is a new alien language which uses ...

  4. 【.Net设计模式系列】工作单元(Unit Of Work)模式 ( 二 )

    回顾 在上一篇博客[.Net设计模式系列]仓储(Repository)模式 ( 一 ) 中,通过各位兄台的评论中,可以看出在设计上还有很多的问题,在这里特别感谢 @横竖都溢 @ 浮云飞梦 2位兄台对博 ...

  5. jsp中submit的连接属性是什么?

    把注册的按钮改成button:<form action="dologin.jsp" method="post">用户<input type=& ...

  6. windows下安装php性能分析工具XHProf

    一.安装扩展 下载XHProf扩展:http://dev.freshsite.pl/php-extensions/xhprof.html 放入扩展文件:下载后解压出.dll文件,拷贝它到php的ext ...

  7. mysql5.7 源码安装步骤

    操作系统:centos 7 mysql版本:5.7  下载地址:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-gli ...

  8. synchronized的原理与使用

    理论层面: 内置锁与互斥锁 修饰普通方法.修饰静态方法.修饰代码块 demo如下: package com.roocon.thread.t3; public class Sequence { priv ...

  9. Anriod手机抓包

    1. 下载Fiddler http://fiddler2.com/ 2. 开启Fiddler的远程连接,Fiddler 主菜单 Tools -> Fiddler Options--> Co ...

  10. AxB Proplem(大数乘法)

    描述 Redraiment碰到了一个难题,需要请你来帮忙:给你两个整数,请你计算A × B. 输入 数据的第一行是整数T(1 ≤ T ≤ 20),代表测试数据的组数. 接着有T组数据,每组数据只有一行 ...