zoukankan      html  css  js  c++  java
  • python添加fluent日志记录-aop

    python添加fluent日志,aop实现

    1.配置fluent相关信息

    fluent_config.ini

    fluent_config.ini
    [fluent.aop]
    #is support fluent log   false
    #aop total switch
    fluent.aopStatus=true
    #project name
    project.name=py-web-base
    #fluent join info
    # not istio
    fluent.url=192.168.181.99
    fluent.port=30224
    #istio
    #fluent.url=fluentd-es.logging
    #fluent.port=24224

    2.拦截使用

    1)注解形式

    在需要添加aop fluent日志的方法头部添加

    @InvocationLoggerAspect

     
    2)显示调用

    在需要添加aop fluent日志方法 定义之后,调用之前添加

    methodName = InvocationLoggerAspect(methodName)

    3.添加业务日志

    from aop.aspectAop import InvocationLoggerAspect
    fluent = FluentInit.FluentInit()
    sender.setup(fluent.project_name, host=fluent.fluent_url, port=int(fluent.fluent_port))

     

    4.业务单个请求记录fluent

    假如总开关关闭(fluent.aopStatus=flase),但是需要记录某个请求的日志,则只需要在请求中添加参数fluent.aopStatus=true即可。

     

    5.事例项目

    https://github.com/jiuchongxiao/python-fluent-aop

    事例说明:

    aop文件夹下为 fluent aop核心代码,配置文件fluent_config.ini在此目录下

    测试代码:为fluentTestApp.py 和 fluentTestAppWeb.py

  • 相关阅读:
    springboot整合springmvc原理
    springboot Thymeleaf
    springboot 首页处理
    springboot整合Druid
    springboot 整合JDBC
    CentOS安装Mysql
    springboot 多环境切换
    springboot JSR303数据校验
    【转载】WEB架构师成长之路
    一些想法
  • 原文地址:https://www.cnblogs.com/jiuchongxiao/p/9134779.html
Copyright © 2011-2022 走看看