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. 多继承以及MRO顺序

    class A: def test(self): print("A --- test方法") def demo(self): print("A --- demo方法&qu ...

  2. c语言数组越界的避免方法

    1.尽量显式地指定数组的边界 #define MAX 10 - int a[MAX]={1,2,3,4,5,6,7,8,9,10}; 在 C99 标准中,还允许我们使用单个指示符为数组的两段" ...

  3. Django --- 路由层(urls)

    目录 1.orm表关系如何建立 2.django请求生命周期流程图 3.urls.py路由层 4.路由匹配 5.无名分组 6.有名分组 7.反向解析 8.路由分发 9.名称空间 10.伪静态 11.虚 ...

  4. 洛谷P2661 信息传递【并查集】

    题目:https://www.luogu.org/problemnew/show/P2661 题意: 有一个有向图,问最小环的的大小. 思路: 明明是图的遍历,但是bfs会T.第二组下下来的数据n居然 ...

  5. LightOJ - 1179-Josephus Problem(约瑟夫环)

    链接: https://vjudge.net/problem/LightOJ-1179 题意: The historian Flavius Josephus relates how, in the R ...

  6. HTML 005 标题

    <h1>这是一个标题.</h1> <h2>这是一个标题.</h2> <h3>这是一个标题.</h3> HTML 标题 在 HTM ...

  7. MVC4 Application Install

    For VS2010 http://www.asp.net/mvc/mvc4 For VS2012 http://www.asp.net/downloads

  8. 携程移动端案列(flex布局、背景图缩放,文字阴影)

    效果图如下: <body> <div class="nav"> <div class="row"> <div clas ...

  9. 2019-2020 ICPC, NERC, Southern and Volga Russian Regional Contest

    目录 Contest Info Solutions A. Berstagram B. The Feast and the Bus C. Trip to Saint Petersburg E. The ...

  10. Unity的资源加载以及AssetBundle的一些坑

    https://www.cnblogs.com/sigmadruid/p/4040803.html AssetBundle加载完毕,进行其中Asset的初始化后,不能立即Unload().否则Asse ...