zoukankan      html  css  js  c++  java
  • Django中的logging

    对网站、微服务来说,log(日志)是比较重要的运维工具。 Django的log,主要是复用Python标准库中的logging模块,在settings.py中进行配置。 此外,也提供了一些独特的扩展。

    settings.py

    TIME_ZONE = 'Asia/Shanghai'
    
    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {   #有这个配置在,可以不用修改系统的配置
            'verbose': {
                'format': '{asctime} {module}.{funcName} {lineno:3} {levelname:7} => {message}', 
            #asctime> 2018-11-15 module> 是模块名 funcName>函数名 lineno:3>至少显示3个字符 少则补空格 levelname>是log级别 message>是log内容 'style': '{', }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'formatter': 'verbose', }, 'file': { 'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'verbose', 'filename': '/tmp/django.log', 'maxBytes': 4194304, # 4 MB 'backupCount': 10, 'level': 'DEBUG', }, }, 'loggers': { '': { 'handlers': ['console', 'file'], 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'django': { 'handlers': ['console', 'file'], 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), 'propagate': False, }, }, }
  • 相关阅读:
    [LuoguP1445][LOJ#10202]樱花
    [APIO/CTSC2007]动物园
    [LOJ#10157]皇宫看守
    python3安装crypto出错,及解决方法
    Qt之QuaZip编译-使用教程
    CentOS-NAT模式下(DHCP)联网
    CentOS桌面环境中网卡启动失败
    Linux基础--基础命令
    Linux基础 --1
    python面试题----4
  • 原文地址:https://www.cnblogs.com/xzqpy/p/11391913.html
Copyright © 2011-2022 走看看