How to use log levels in java

2019-03-12 04:14发布

I am developing an application where i need to use the logger functionality. I have read about different levels of logger which are:

  • SEVERE (highest)
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST

I am not able to understand the usage of each logging level.

Can someone give me a good example showing all the logging levels and their usage?

标签: java logging
9条回答
放我归山
2楼-- · 2019-03-12 04:49

Logging has different levels such as :
Trace – A fine-grained debug message, typically capturing the flow through the application. Debug- A general debugging event should be logged under this.
ALL – All events could be logged.
INFO- An informational purpose, information written in plain english.
Warn- An event that might possible lead to an error.
Error- An error in the application, possibly recoverable.

Logging captured with debug level is information helpful to developers as well as other personnel, so it captures in broad range. If your code doesn't have exception or errors then you should be alright to use DEBUG level of logging, otherwise you should carefully choose options.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-12 04:53

the different log levels are helpful for tools, whose can anaylse you log files. Normally a logfile contains lots of information. To avoid an information overload (or here an stackoverflow^^) you can use the log levels for grouping the information.

查看更多
The star\"
4楼-- · 2019-03-12 04:54

The use of levels is really up tp you. You need to decide what is severe in your application, what is a warning and what is just information. You need to split your logging so that your users can easily set up a level of logging that doesn't kill the system with excessing IO but which will report serious errors so you can fix them.

查看更多
登录 后发表回答