log4j的优点 [英] Advantage of log4j

查看:156
本文介绍了log4j的优点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

log4j 优于set System.out System.err 输出到日志文件?

What's the advantage of log4j over set System.out and System.err to output to a log file?

推荐答案

从较高的层面来说,Log4j胜过人工记录是您可以将日志记录代码与实际要记录的内容以及记录位置和方式进行分离。有关记录详细程度/过滤,格式化,日志位置,甚至日志类型(文件,网络等)的详细信息都是使用配置以声明方式处理,并可通过自定义附加程序,而不必自己编写灵活性代码。

At a high level, the win from Log4j over manual logging is that you can decouple your logging code from what you actually want to log and where and how you want to log it. Details about logging verbosity/filtering, formatting, log location, and even log type (files, network, etc.) are handled declaratively using configuration and extensibly via custom appenders, rather you having to code that flexibility yourself.

这一点至关重要,因为开发人员通常很难预测一旦软件投入生产后日志记录需求会如何变化。管理该软件的运营团队可能需要更少的详细日志,可能需要多个日志,可能需要将这些日志发送到多个服务器,有时可能需要获得真正详细的数据以进行故障排除等。如果需要,运营团队通常不可能改变日志记录的工作方式,说服开发人员进行大的代码更改。这通常会导致生产停机,操作和开发之间的摩擦,以及浪费时间。

This is critically important because it's often hard for developers to predict how logging needs will change once their software is in production. Operations teams managing that software may need less verbose logs, may need mulitple logs, may need to ship those logs to multiple servers, may need to sometimes get really verbose data for troubleshooting, etc. And it's usually impossible for operations teams, if they need to change how logging works, to convince the developer to make big code changes. This often leads to production downtime, friction between operations and development, and wasted time all around.

从开发人员的角度来看,Log4j使您无需进行代码更改支持日志记录,并使您不会被希望记录更改的人所困扰。它使管理代码的人能够抓住他们自己的痒而不是惹恼你!

From the developer's point of view, Log4j insulates you from having to make code changes to support logging, and insulates you from being pestered by people who want logging changes. It enables people managing your code to scratch their own itch rather than bugging you!

此外,由于Log4j是Java日志记录的事实标准,因此有很多工具可以使用Log4j做一些很酷的东西 - 这进一步阻止你和你的运营团队重新发明轮子。

Also, since Log4j is the de-facto standard for Java logging, there are lots of tools available which can do cool things with Log4j-- furthermore preventing you and your operations teams from re-inventing the wheel.

我最喜欢的功能是能够轻松编写appender发送数据到非文件来源,如 SYSLOG Splunk 等,使您的应用程序可以轻松自定义登录到您的IT部门已经使用的操作管理工具。

My favorite feature is the ability to easily write appenders send data to non-file sources, like SYSLOG, Splunk, etc. which makes it easy to your app's custom logging into operations management tools your IT department is already using.

这篇关于log4j的优点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆