日志和崩潰報告在PHP顯示總結
什么是日志,為什么我們關心日志?
日志是從運行過程中收集的時間順序事件流
日志可以產生大量的輸出
日志允許我們通過告訴我們關于我們的系統的原因:
發生了什么事
當它發生
為什么會發生
我們可以用工具來幫助我們
基于查詢分離相關事件
通知我們有關重要事件(例如:通過電子郵件,松弛等)
我們應該記錄什么?
一般來說,登錄更多而不是更少
有些事情我們不應該記錄:
密碼
個人資料
軟件與過濾可以幫助這個
日志過多會影響性能
測井在PHP中的事實上的標準是psr-3和最常見的日志庫的獨白。
psr-3定義大量的日志級別。我們應該使用多少?
調試,信息,警告和錯誤可能是足夠的大多數應用程序
我們使用的水平是基于syslog RFC
這取決于你的應用程序的規模
我們如何可視化日志?
尾- F
麋鹿堆棧是受歡迎的,快速和(相對)容易建立
Elasticsearch指標日志和使他們的搜索
Logstash整理的數據從不同的日志源
Kibana是分析數據可視化層
我們應該在哪里寫日志?
平面文件和logrotate
緩沖系統像Redis或卡夫卡
將日志發送到聚合服務
Logging & Crash Reporting in PHP Show Summary
What are logs and why do we care about logging?
Logs are streams of time-ordered events collected from a running process
Logging can generate huge amounts of output
Logs allow us to reason about our systems by telling us:
What is happening
When it is happening
Why it is happening
We can use tools to help us to
Isolate relevant events based on queries
Notify us about important events (e.g: by email, slack, etc)
What should we log?
In general, log more rather than less
There are some things we should not log:
Passwords
Personal data
Software with filtering can help with this
Logging too much can impact performance
The de-facto standard for logging in PHP is PSR-3 and the most common logging library is monolog.
PSR-3 Defines a lot of log levels. How many should we use?
DEBUG, INFO, WARNING and ERROR is probably enough for most apps
The levels we use are based on the syslog RFC
It depends on the scale of your application
How can we visualize logs?
tail -f
The ELK Stack is popular, fast and (relatively) easy to set up
Elasticsearch indexes logs and makes them searchable
Logstash collates the data from different log sources
Kibana is the visualization layer for analyzing the data
Where should we write logs?
Flat files and logrotate
A buffering system like Redis or Kafka
Send logs to an aggregation service