celery的log如何传递给django,由django管理
celery自己管理log目录
celery worker --autoscale=4,1 --app=erebus.celeryapp:app -l info -f /home/admin/output/erebus/logs/worker.log -Q erebus,celery
celery beat --loglevel info --app erebus.celeryapp:app --logfile /home/admin/output/erebus/logs/beat.log
celery flower -A erebus.celeryapp:app --broker=sentinel://:password@ip:26379/6 --basic_auth=flower:flower,user:password
日志给django管理
配置EREBUS_WORKER_HIJACK_ROOT_LOGGER=False 参考配置的日志选项:http://docs.celeryproject.org/en/latest/userguide/configuration.html
django的日志配置:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
# 后缀d表示数据格式是整数,s表示数据格式是字符串
'format': '[%(levelname)s] [%(asctime)s] [%(module)s] %(filename)s:%(lineno)d %(funcName)s '
'%(processName)s:[%(process)d] %(threadName)s:[%(thread)d] %(message)s'
# 'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
# 'style': '{',
},
'simple': {
'format': '[%(levelname)s] [%(asctime)s] %(message)s',
# 'format': '[%(asctime)s] %(message)s',
# 后缀d表示数据格式是整数,s表示数据格式是字符串
# 'format': '[%(levelname)s] [%(asctime)s] [%(module)s] %(filename)s:%(lineno)d %(funcName)s '
# '%(processName)s:[%(process)d] %(threadName)s:[%(thread)d] %(message)s',
# 'style': '{',
},
'standard': {
# 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
'format': '{asctime} [{levelname:7}] {name:30}: {message}',
# 设置上面格式样式;{levelname:3}是告警级别,至少显示7个字符,少则补空格;多则正常显示
# 这里style选择{,是指{asctime}这种形式。
# 如果选择%,则是%(asctime)s这种形式。
# 还有一种选择,是$,是$asctime或${asctime}这种形式。
'style': '{',
# 设置时间格式
'datefmt': '%Y-%m-%d %H:%M:%S',
},
'operation': {
'format': '%(message)s'
}
},
# 'filters': {
# # 'special': {
# # '()': 'erebus.logging.SpecialFilter',
# # 'foo': 'bar',
# # },
# 'require_debug_true': {
# '()': 'django.utils.log.RequireDebugTrue',
# },
# },
# Handler是决定如何处理logger中每一条消息的引擎。它描述特定的日志行为,比如把消息输出到屏幕、文件或网络socket。
# 和 logger 一样,handler 也有日志级别的概念。如果一条日志记录的级别不匹配或者低于 handler 的日志级别,
# 对应的消息会被 handler 忽略。
'handlers': {
'default': {
# 'level': 'WARNING',
# 'class': 'logging.handlers.RotatingFileHandler',
# 'filename': '{}/default.log'.format(BASE_LOG_DIR),
# 'maxBytes': 1024*1024*5*20, # 5*20 MB
# 'maxBytes': 1024*5, # 5 KB
# 保留7天的日志,没份5M,5份大概是一个小时的日志内容,主要是kafka日志
# 'backupCount': int(5*1*24*7/20),
# 'formatter': 'standard',
'level': 'WARNING', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'app.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'pipeline': {
# 'level': 'DEBUG',
# 'class': 'logging.handlers.RotatingFileHandler',
# 'filename': '{}/pipeline.log'.format(BASE_LOG_DIR),
# 'maxBytes': 1024*1024*5*20, # 5*20 MB
# 'maxBytes': 1024*5, # 5 KB
# 保留7天的日志,没份5M,5份大概是一个小时的日志内容,主要是kafka日志
# 'backupCount': int(5*1*24*7/20),
# 'formatter': 'standard',
'level': 'DEBUG', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'pipeline.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'kafka': {
# 'level': 'DEBUG',
# 'class': 'logging.handlers.RotatingFileHandler',
# 'filename': '{}/kafka.log'.format(BASE_LOG_DIR),
# 'maxBytes': 1024*1024*5*20, # 5*20 MB
# 'maxBytes': 1024*5, # 5 KB
# 保留7天的日志,没份5M,5份大概是一个小时的日志内容,主要是kafka日志
# 'backupCount': int(5*1*24*7/20),
# 'formatter': 'standard',
'level': 'INFO',
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'kafka.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'output_to_server': {
'level': 'WARNING', # 忽略debug/info信息
'class': 'logging.handlers.HTTPHandler',
'host': '127.0.0.1:8088',
'url': '/api/v1/log',
# 使用GET方法遇到url最大长度限制
'method': 'POST',
'formatter': 'verbose',
},
'jenkins': {
'level': 'DEBUG', # 忽略debug信息
'class': 'logging.handlers.RotatingFileHandler',
'filename': '{}/{}.log'.format(BASE_LOG_DIR, 'jenkins'),
'formatter': 'simple' if DEBUG else 'verbose',
'encoding': 'utf8',
'maxBytes': 1024*1024*5*20, # 5*20 MB
'backupCount': int(5*1*24*7/20),
},
'django': {
# 'level': 'INFO', # 忽略debug信息
# 'class': 'logging.handlers.RotatingFileHandler',
# 'filename': '{}/{}.log'.format(BASE_LOG_DIR, conf.get('log', 'name')),
# 'formatter': 'simple' if DEBUG else 'verbose',
# 'encoding': 'utf8',
# 'maxBytes': 1024*1024*5*20, # 5*20 MB
# 'backupCount': int(5*1*24*7/20),
'level': 'INFO', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': '{}.log'.format(conf.get('log', 'name')),
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'gunicorn_error': {
'level': 'INFO', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'gunicorn_error.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'gunicorn_access': {
'level': 'INFO', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'gunicorn_error.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'celery': {
'level': 'INFO', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'celery.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'flower': {
'level': 'INFO', # 忽略debug信息
'class': 'utils.graylog.graylog_django.GraylogHandler',
'app': 'erebus',
'file': 'flower.log',
'host': GRAYLOG_HOST,
'port': GRAYLOG_PORT,
'localname': GRAYLOG_SOURCE,
},
'console': {
'level': 'DEBUG' if DEBUG else 'WARNING', # 所有的日志都会被输出到console
# 'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'operation': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '{}/{}.log'.format(BASE_LOG_DIR, 'operation'),
'formatter': 'operation',
'encoding': 'utf8'
},
'test': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '{}/{}.log'.format(BASE_LOG_DIR, 'test'),
'formatter': 'standard',
'encoding': 'utf8'
}
# 'mail_admins': {
# 'level': 'ERROR',
# 'class': 'django.utils.log.AdminEmailHandler',
# # 'filters': ['special']
# }
},
'loggers': {
# 可以通过使用空字符串:''来设置'catch all' logger
# 在以下设置中,将所有日志事件级别为WARNING及以上的日志发送给日志服务器,但配置为'propagate': False日志事件除外,
'': {
'handlers': ['default', 'output_to_server'],
# 'handlers': ['default'],
# 这样情况下的level设置是无效的,所有级别的信息都会传给handlers处理,由handlers的level界别决定
# 'level': 'ERROR',
'propagate': False
},
# 记录所有jenkins的requests相关的日志;jenkins->requests->urllib3
'urllib3': {
'handlers': ['jenkins'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': True
},
# 记录所有kakfa相关的日志kafka.conn/kafka.client/kafka.coordinator.consumer
'kafka': {
'handlers': ['kafka'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': True
},
# 这里必须使用名字django和django.request,目的是为了捕获django框架的日志内容
'django': {
'handlers': ['django', 'console'],
# 当 logger 处理一条消息时,会将自己的日志级别和这条消息的日志级别做对比。
# 如果消息的日志级别匹配或者高于 logger 的日志级别,它就会被进一步处理。
# 否则这条消息就会被忽略掉。当 logger 确定了一条消息需要处理之后,会把它传给 Handler。
# 把INFO及以上级别的日志传给handlers,然后由handlers根据handlers的level进一步处理日志输出
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': True, # 若值为False,表示日志不会传到上个层级,自然也不会传到default.log里
},
# 使用logger = logging.getLogger('django.request'), logger.info('info'),
# 可以把日志输出到'handlers': ['django', 'console'],
'django.request': {
# 即使和django的handlers一样,level也一样,也并不会产生2次相同的日志内容,应该是个并集。
'handlers': ['django', 'console'],
'level': 'DEBUG' if DEBUG else 'INFO',
# 会把日志向django.request的上层django传播
'propagate': True,
},
# sql语句
'django.db.backends': {
# 即使和django的handlers一样,level也一样,也并不会产生2次相同的日志内容,应该是个并集。
'handlers': ['django', 'console'],
'level': 'DEBUG' if DEBUG else 'INFO',
# 会把日志向django.request的上层django传播
'propagate': True,
},
# 'erebus.custom': {
# 'handlers': ['console', 'mail_admins'],
# 'level': 'INFO',
# # 'filters': ['special']
# },
# 名字随意起,用时,使用logger = logging.getLogger(conf.get('log', 'name'))获取,传到相应的loggers里就可以
'operation': {
'handlers': ['operation'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': True,
},
'test': {
'handlers': ['console', 'test'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
},
'pipeline': {
'handlers': ['pipeline'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
},
'gunicorn.error': {
'handlers': ['gunicorn_error'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
},
'gunicorn.access': {
'handlers': ['gunicorn_access'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
},
'celery': {
'handlers': ['celery'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
},
'flower': {
'handlers': ['flower'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False, # 不要传给上一层级
}
}
}
celery的log如何传递给django,由django管理的更多相关文章
- gunicorn的log如何传递给django,由django管理
gunicorn配置文件为gunicorn_config.py里面有日志的配置 # errorlog = '/home/admin/output/erebus/logs/gunicorn_error. ...
- django中将views.py中的python方法传递给html模板文件
常规的模板渲染 from django.db import models # Create your models here. class ArticalType(models.Model): cap ...
- JavaWeb -- 服务器传递给Servlet的对象 -- ServletConfig, ServletContext,Request, Response
1. ServletConfig 有一些东西不合适在程序中写死,应该写在web.xml中,比如 文字怎么显示, 访问数据库名 和 密码, servlet要读取的配置文件 等等.. l在Servle ...
- 如何获取url中的参数并传递给iframe中的报表
在使用报表软件时,用户系统左边一般有目录树,点击报表节点就会在右侧网页的iframe中显示出报表,同时点击的时候也会传递一些参数给网页,比如时间和用户信息等.如何使网页中的报表能够获取到传递过来的参数 ...
- AWK调用SHELL,并将变量传递给SHELL
在Shell脚本中调用awk是非常自然和简单的,以前还写过一个关于awk/shell相互传递变量的文章:awk与shell之间的变量传递方法在awk脚本中,如果需要调用shell脚本/命令,则需要使用 ...
- Jmeter----A接口response中body的某一个参数传递给B接口request的body中使用(参数的传递)
示例:将接口"获取待办列表"response中body的id值传递给接口"删除待办"request的body中使用: 操作步骤如下: 第一步:给"获取 ...
- 微软将把Windows Defender防火墙传递给 Linux 子系统
前不久,微软以 Azure Sphere OS 的形式发布了自己的 Linux 版本.而在最新的开发中,该公司又决定将其 Windows Defender 防火墙的传递给 Linux 子系统(WSL) ...
- 详解~实现Runnable方法创建线程之为什么要将Runnable接口的子类对象传递给Thread的构造函数
/** * @author zhao * @TIME 0419 22:56 End *定义线程的第二种方法:实现Runnable接口(不考虑安全问题) *步骤:1,定义一个子类实现Runnable接口 ...
- 通过BeanShell获取UUID并将参数传递给Jmeter
有些HTTPS请求报文的报文体中包含由客户端生成的UUID,在用Jmeter做接口自动化测试的时候,因为越过了客户端,直接向服务器端发送报文,所以,需要在Jmeter中通过beanshell获取UUI ...
随机推荐
- 原生js手机端触摸下拉刷新
废话不多说,直接上代码,这里感谢我的好朋友,豆姐 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
- php数据类型之浮点型
所谓浮点类型,可以理解为:我们数学里面的小数. [注意]关于精度.取值范围和科学型声明不是学习的重点.因为此块在实际开发中用的特别少.我们将此块的知识点的学习标注为,了解级别.直线电机滑台 声明方式分 ...
- IDEA八条配置修改
IDEA版本:IntelliJ IDEA 2019.2.1 x64 八条配置修改: 自动编译开关 忽略大小写开关 智能导包开关 悬浮提示开关 取消单行显示tabs的操作 项目文件编码 滚轴修改字体大小 ...
- 011——C#创建ecxel文件(附教程)
(一)参考文献:[C#]创建表格(.xlsx)的典型方法 (二)视频教程:https://v.qq.com/x/page/t30068qfex5.html (三)下载地址:https://downlo ...
- Greenplum 函数 gp_dist_random
转载自:https://yq.aliyun.com/articles/7593 函数作用: gp_dist_random('gp_id')本质上就是在所有节点查询gp_id, gp_dist_rand ...
- 十一.简单MariaDB数据库的管理
默认端口:3306 1.安装 ]# yum -y install mariadb-server ]# systemctl restart mariadb 2.基本操作 ]# mysql #进入 ]&g ...
- hihoCoder 1785
线性筛 + 递推 #include <bits/stdc++.h> , Mod = 1e9 + ; int n; int phi[N], prime[N], tot, ans; bool ...
- 爬虫(五):PyQuery的使用
一:简介 PyQuery库是jQuery的Python实现,可以用于解析HTML网页内容,是一个非常强大又灵活的网页解析库. -->官方文档地址 -->jQuery参考文档 二:初始化 初 ...
- linux系列(二十二):tar命令
1.命令格式 tar[必要参数][选择参数][文件] 2.命令功能 用来压缩和解压文件.tar本身不具有压缩功能.他是调用压缩功能实现的 3.命令参数 必要参数: -A 新增压缩文件到已存在的压缩 - ...
- pc页面自动缩放到手机端
今天做了个pc的页面,看了别人的网站在手机端能把pc端的网页刚好缩放到手机端,看着很舒服. 于是想把自己的页面也这样搞一下,刚开始,想到的是利用css3的缩放来做,想的是当屏幕尺寸改变时缩放整个页面, ...