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

python添加fluent日志记录-aop的更多相关文章

  1. python添加fluent日志记录

    istio默认会进行日志的记录,但是仅仅记录到服务.以及服务之间调用的信息,不记录业务日志. 如: 所以需要添加业务日志记录. 1.python引入package fluentmsgpack 2.代码 ...

  2. springboot添加fluent日志记录

    istio默认会进行日志的记录,但是仅仅记录到服务.以及服务之间调用的信息,不记录业务日志. 如: 所以需要添加业务日志记录. 1.引入依赖 <dependency>     <gr ...

  3. spring/spirng boot添加fluent日志-aop

    此项目以aop的形式添加fluent 日志 sample介绍 spring-mvc-aop-helloworld 为spring mvc aop condition toolcommontest 为s ...

  4. Python开发之日志记录模块:logging

    1 引言 最近在开发一个应用软件,为方便调试和后期维护,在代码中添加了日志,用的是Python内置的logging模块,看了许多博主的博文,颇有所得.不得不说,有许多博主大牛总结得确实很好.似乎我再写 ...

  5. 接口日志记录AOP实现-LogAspect

    使用spring aop日志记录 所需jar包 pom.xml <!-- logger begin --> <dependency> <groupId>org.sl ...

  6. .NET Worker Service 添加 Serilog 日志记录

    前面我们了解了 .NET Worker Service 的入门知识[1] 和 如何优雅退出 Worker Service [2],今天我们接着介绍一下如何为 Worker Service 添加 Ser ...

  7. Yii2如何添加sql日志记录的配置信息

    在使用Yii2框架的时候,常常会出现没有sql日志记录的问题.在代码里一句一句的打印sql语句也不现实.所以就要用文件记录起来. 在 config/web.php 里面的 log配置中增加如下配置 [ ...

  8. Python中的日志记录方案-logging模块&loguru模块

    原文链接 原创: 崔庆才 在 Python 中,一般情况下我们可能直接用自带的 logging 模块来记录日志,包括我之前的时候也是一样.在使用时我们需要配置一些 Handler.Formatter ...

  9. .net 项目如何添加log4net日志记录

    1.在项目根目录新建文件log4net.config,此文件中的节点解释还请自动百度. 文件实例: <?xml version="1.0"?><configura ...

随机推荐

  1. Hibernate 再接触 ID生成策略

    Xml 方法 在student.hbm.xml中 <generator class="uuid"></generator> 取值如下 1.identity: ...

  2. Oracle监听程序未启动或数据库服务未注册到该监听

    oracle新建数据库的时候提示Could not find appropriate listener for this database要做的操作如下: 1.查看netmanager里面的liste ...

  3. Java中String的intern方法,javap&cfr.jar反编译,javap反编译后二进制指令代码详解,Java8常量池的位置

    一个例子 public class TestString{ public static void main(String[] args){ String a = "a"; Stri ...

  4. SSH 登录时出现如下错误:Disconnected:No supported authentication methods available

    SSH 登录时出现如下错误:Disconnected:No supported authentication methods available 更新时间:2017-06-07 13:26:11   ...

  5. Html----编写

    文档的编辑 选择文档---->修改文档后缀名(.thml)--->用浏览器打开(解释和执行HTML源代码的工具) 浏览器主要分类及内核 火狐(Firefor)--->Gecho IE ...

  6. php首字母 大写 数组去重复

    $zimu[]=strtoupper(substr( $value['title'], 0, 1 ));//大写 $zimu[]=strtolower(substr( $value['title'], ...

  7. MySQL driver for Node

    [MySQL driver for Node] 1.安装 2.一个示例 From this example, you can learn the following: Every method you ...

  8. Unity中的四个路径

    Application.database:当前工程的Assets文件夹(编辑器) Application.StreamingAssets:IO流路径 当前工程的StreamingAssets文件夹(编 ...

  9. scrapy 是指user_agent

    1.倒入random模块 2.在settings文件中添加useragent列表 MY_USER_AGENT = [ "Mozilla/4.0 (compatible; MSIE 6.0; ...

  10. Java输入输出流详解(转)

    转自:http://blog.csdn.net/zsw12013/article/details/6534619