我将在我的 Web 应用程序中使用 Log4j,我是新手。 Log4j 的用途是什么以及我如何在我的应用程序中使用它。提前致谢。
最佳答案
我认为Log4J home page提供了其使用背后的最佳概述和基本原理。
With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary.
Logging equips the developer with detailed context for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool.
除此之外,使用 Log4J,您可以动态地打开/关闭日志记录。您可以动态更改格式(您想要时间戳吗?日期戳?)并且您可以更改日志记录的位置(到控制台?到文件?到数据库?),所有这些都不需要更改您的代码。
关于log4j - Log4j API 有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1492309/