`
septem
  • 浏览: 54475 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Logging Best Practices

    博客分类:
  • java
阅读更多
像日志的这样的小细节,在开发过程中常常被忽略。除了区分级别外,日志的输出内容通常处理地很随意。而实际上日志在监控系统行为,排错,性能优化,安全审计等方面扮演着重要的角色。

总体上说一份良好的日志应该符合一个特性:greppable。grep是unix/linux系统上一个很强大的工具,它能够从文件中找出匹配某个正则表达式的所有行。也就是说良好的日志文件应该能够让日志分析工具在庞大的日志数据里很容易很精准地定位到所需要的信息。

至于如何才算greppable,还得看具体的分析需求,总结一下考虑的因素大概有以下几个方面:

一、what to log? 需要纪录哪些信息

错误信息,核心性能数据,用户行为数据,安全验证信息等等,要根据将来需要对日志做哪些分析来选择纪录相应的数据

二、log design
1、单独的日志信息要纪录在一行数据里面,因为像grep之类的工具无法跨行匹配,如果一条日志信息会跨行的话,会加大日志分析的难度
2、日志要纪录分析所需的必要信息,并且要避免冗余,与其它无关的信息区分开来,方便分析工具快速定位核心信息
3、日志文件要分级与模块化,不同的模块对应不同的日志文件,易于快速定位问题

总结:好的日志应该准确纪录系统的行为,而且在内容与格式上是grep-friendly,能够让日志分析工具在庞大的日志文件里很容易很精准地定位到所需要的数据
2
0
分享到:
评论

相关推荐

    Two Scoops of Django 1.11: Best Practices for the Django Web Framework.pdf

    Chapter 9: Best Practices for Function-Based Views Chapter 10: Best Practices for Class-Based Views Chapter 11: Form Fundamentals Chapter 12: Common Patterns for Forms Chapter 13: Templates: Best ...

    Splunk.Best.Practices.1785281399

    Next, you'll discover the best practices in logging, operations, knowledge management, searching, and reporting. To finish off, we will teach you how to troubleshoot Splunk searches, as well as ...

    Defensive Security Handbook: Best Practices for Securing Infrastructure

    Defensive Security Handbook: Best Practices for Securing Infrastructure by Lee Brotherston English | 3 Apr. 2017 | ASIN: B06Y18XC5Y | 268 Pages | AZW3 | 3.88 MB Despite the increase of high-profile ...

    Pro Python Best Practices Debugging

    本书“Pro Python Best Practices Debugging, Testing and Maintenance”深入探讨了这些主题,旨在帮助开发者构建更稳定、更可维护的软件系统。以下是对这些核心概念的详细解读。 **调试**: 调试是找出并修复程序...

    Pro Python Best Practices.pdf

    本书名为《Pro Python Best Practices: Debugging, Testing and Maintenance》,作者为Kristian Rother,由Springer Science+Business Media出版,首次发行于2018年。这是一本专注于Python编程最佳实践的专业图书,...

    IT_Security_Guidelines_TLS.pdf

    15Public Key Pinning (HPKP) 15Client authentication 164 Deployment and monitoring 17TLS logging 17TLS testing tools 17TLS performance 18TLS deployment best practices 185 Incident response 196 ...

    Secure Java: For Web Application Development

    The authors provide in-depth implementation guidance and best practices for access control, cryptography, logging, secure coding, and authentication and authorization in web application development....

    Go in Practice.pdf

    - Best practices for logging and reporting errors. By mastering these techniques, developers can create more reliable and user-friendly applications. **Chapter 5: Debugging and Testing** Testing is a...

    Java - J2EE Job Interview Companion.pdf

    By following best practices and considering the potential drawbacks, developers can effectively leverage Log4j to improve the reliability, maintainability, and performance of their applications.

    Agile Java Crafting Code with Test-Driven Development

    Brings together practical best practices for Java, TDD, and OO design Walks through setting up Java 5.0 and writing your first program Covers all the basics, including strings, packages, and more ...

    MongoDB Data Modeling(PACKT,2015)

    Finally, we will talk about best practices that will help you optimize and manage your database, presenting you with a real-life example of data modeling on a real-time logging analytics application.

    配置抵御SQL注入试攻击的服务器.pdf

    配置抵御 SQL 注入试攻击的服务器需要从多个方面入手,包括了解 SQL 注入攻击、配置服务器抵御 SQL 注入攻击、 SQL 服务器安全配置、Web 应用程序安全配置、数据库安全配置、防止 SQL 注入攻击的best practices 等。...

    Hands-On Continuous Integration and Delivery

    Hands-On Continuous Integration and Delivery starts ...By the end of this book, you will have a detailed understanding of best practices for CI/CD systems and be able to implement them with confidence.

    Python_Development_Best_Practices:Python软件开发最佳实践资源

    14. **日志记录**:合理使用`logging`模块,记录程序运行状态,便于调试和问题排查。 15. **性能优化**:了解Python的性能瓶颈,如GIL(全局解释器锁)对多线程的影响,适时使用`multiprocessing`库进行并行计算。 ...

    log4j-tutorial.zip_How To Change It

    This tutorial explains how to set up log4j with email, files and stdout. It compares XML to properties configuration files, ...Furthermore, we explain best practices on logging and exception handling.

    Building Python Real-Time Applications with Storm 无水印pdf 0分

    Discover how to apply software development best practices to improve performance, productivity, and quality in your Storm projects Who This Book Is For This book is intended for Python developers who ...

    Software Architecture with Python-Packt Publishing(2017).epub

    Chapter 6, Security Writing Secure Code, discusses the security aspect of architecture and teaches you best practices and techniques of writing applications that are secure. You will understand the ...

    MongoDB.Data.Modeling.1782175342

    Finally, we will talk about best practices that will help you optimize and manage your database, presenting you with a real-life example of data modeling on a real-time logging analytics application....

Global site tag (gtag.js) - Google Analytics