How to implement/use log4j? [closed]

2019-02-07 06:52发布

I am soon going to use log4j class using Java, for a project, to create logs. But i dont think i know or have any slightest idea about it. Hope someone enlightens me over this, but, trivial issue.

2条回答
成全新的幸福
2楼-- · 2019-02-07 07:13

Log4j basically takes any statement you want to output, lets you assign a "severity" level to it (warning, error, critical, etc) and logs it out in a variety of ways. (to a file, to a byte stream, etc. there are lots of appender options available.);

Here's a short blurb introduction to log4j.
http://www.developer.com/open/article.php/3097221/Logging-with-log4jmdashAn-Efficient-Way-to-Log-Java-Applications.htm

Here's a short tutorial:
http://veerasundar.com/blog/2009/07/log4j-tutorial-adding-log4j-logging-to-your-project/

查看更多
放我归山
3楼-- · 2019-02-07 07:15

Log4j is very easy to use. Try the manual.

Also lots of people use commons logging to wrapper log4j, if you are sure you want to use log4j for the long term then use it directly.

You should also get agreement within your development team what logging levels mean what to your org, for example TRACE & DEBUG are pretty easy. But often people dont have standards as when to use INFO vs WARN vs ERROR. Also what should happen when a log entry of a certain level happens. I like to look at it from the operators point of view, when you see a log level of "FATAL" what do you do? or of "ERROR" etc.

查看更多
登录 后发表回答