python添加fluent日誌記錄-aop

來源:互聯網
上載者:User

標籤:method   rom   tab   開關   strong   aop   value   實現   keyword   

python添加fluent日誌,aop實現

1.配置fluent相關資訊

fluent_config.ini

fluent_config.ini
[fluent.aop]#is support fluent log   false#aop total switchfluent.aopStatus=true#project nameproject.name=py-web-base#fluent join info# not istiofluent.url=192.168.181.99fluent.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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.