Java – advantages of log4j
The advantage of log4j is that the system Out and system Err set to output to log file?
Solution
At a high level, log4j's victory in manual logging is that you can separate the logging code from what you actually want to log, and how to log Details about log details / filtering, formatting, log location, and even log type (file, network, etc.) are declared and processed by using custom Appenders through configuration and extension, and you must write this flexibility yourself
This is very important because it is often difficult for developers to predict how logging requirements will change after software production The operation team managing the software may need fewer detailed logs, may need multiple logs, may need to send these logs to multiple servers, may need to sometimes obtain very detailed data for troubleshooting, etc If necessary, it is often impossible for the operation team to change the working principle of logging to persuade developers to make major code changes This often leads to production downtime, friction between operation and development, and waste of time
From a developer's point of view, log4j absolutely does not require code changes to support logging and protects you from users who need logging changes It allows people to manage your code to scratch their itch, not deceive you!
In addition, since log4j is the de facto standard for Java logging, there are many tools available to do cool things with log4j, which can prevent you and your operation team from reinventing it
My favorite feature is the ability to easily write additional programs to non file sources (such as syslog, Splunk, etc.), making it easy for your application to customize and log in to the operation management tools already used by the IT department