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, }, }, }
  • 相关阅读:
    Leetcode 121. Best Time to Buy and Sell Stock
    Leetcode 120. Triangle
    Leetcode 26. Remove Duplicates from Sorted Array
    Leetcode 767. Reorganize String
    Leetcode 6. ZigZag Conversion
    KMP HDU 1686 Oulipo
    多重背包 HDU 2844 Coins
    Line belt 三分嵌套
    三分板子 zoj 3203
    二分板子 poj 3122 pie
  • 原文地址:https://www.cnblogs.com/xzqpy/p/11391913.html
Copyright © 2011-2022 走看看