What to write into log file?

后端 未结 7 1452
面向向阳花
面向向阳花 2020-12-28 09:28

My question is simple: what to write into a log. Are there any conventions? What do I have to put in?

Since my app has to be released, I\'d like to have friendly log

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 10:00

    In my opinion, best approach is to use existing logging libraries such as log4j (or it's variations for other languages). It gives you control on how your messages are formatted and you can change it without ever touching your code. It follows best practices, robust and used by millions of users. Of course, you can write you own logging framework, but that would be very odd thing to do, unless you need something very specific. In any case, walk though their documentation and see how log statements are presented there.

    Check out log4py - Python ported version of log4j, I think there are several implementations for Python out there..

提交回复
热议问题