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管理的更多相关文章

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

    gunicorn配置文件为gunicorn_config.py里面有日志的配置 # errorlog = '/home/admin/output/erebus/logs/gunicorn_error. ...

  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. Selenium常用API的使用java语言之10-获取断言信息

    不管是在做功能测试还是自动化测试,最后一步需要拿实际结果与预期进行比较.这个比较的称之为断言. 我们通常可以通过获取title .URL和text等信息进行断言.text方法在前面已经讲过,它用于获取 ...

  2. CSP2019 D1T3 树上的数 (贪心+并查集)

    题解 因为博主退役了,所以题解咕掉了.先放个代码 CODE #include<bits/stdc++.h> using namespace std; const int MAXN = 20 ...

  3. Meeting Rooms II

    Description Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2, ...

  4. js中的数据类型以及转换

    Js中的数据类型 Js中的数据类型一共有六种,即number,string,boolean,underfine,null,object. 一,number Number数据类型指的是数字,可以为整型, ...

  5. 011——C#创建ecxel文件(附教程)

    (一)参考文献:[C#]创建表格(.xlsx)的典型方法 (二)视频教程:https://v.qq.com/x/page/t30068qfex5.html (三)下载地址:https://downlo ...

  6. 四十五.加密与解密 AIDE入侵检测系统 扫描与抓包

    一.加密与解密 1.1 常见的加密算法 对称加密:怎么加密,就怎么解密 DES Date Encryption Standard AES Advance Encryption Standard 非对称 ...

  7. zabbix(x)

    问题现象: 客户端设置好自定义监控项,脚本执行或者命令执行都可以正常的输出,但是服务器端通过zabbix-get从客户端获取数据的时候,获取到不正常的值(比如客户端获取到1,服务端获取时显示0或者直接 ...

  8. mysql PS1个性化

    method ) $ export MYSQL_PS1="\u@\h [\d]> " method ) mysql> prompt \u@\h [\d]> met ...

  9. Hive和Hadoop

    我最近研究了hive的相关技术,有点心得,这里和大家分享下. 首先我们要知道hive到底是做什么的.下面这几段文字很好的描述了hive的特性: 1.hive是基于Hadoop的一个数据仓库工具,可以将 ...

  10. 2018-2019-2 网络对抗技术 20165222 Exp 8 Web基础

    1.实践内容 (1).Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. 使用service apache2 start启 ...