Logger vs. System.out.println

前端 未结 6 1781
挽巷
挽巷 2020-12-08 01:59

I\'m using the PMD plugin for eclipse and it gives me an error when using System.out.println() with the explanation:

System.(out|err).pri

6条回答
  •  情书的邮戳
    2020-12-08 02:56

    Loggers has multiple levels for logging.

    If we are writing a real short program, just for learning purposes System.out.println is fine but when we are developing a quality software project, we should use professional logger and SOPs should be avoided.

    A professional loggers provides different levels for logging and flexibility. We can get the log message accordingly. For example, group X messages should be printed only on PRODUCTION, group Y messages should be printed on ERROR, etc.

    We have limited option for redirecting the messages in System.out, but in case of a logger you have appenders which provides numbers of options. We can even create a custom output option and redirect it to that.

提交回复
热议问题