关于Log 的一些东西
關于LOG,思考一下就個問題:
1. 為何有Log
2. Log要如何準確,明白的,分類別的記錄。
3. 如何保證Log信息的安全
?
下面是StackOverflow 一些信息,記錄有待整理
1. 關于Log的一些建議。
I'm basing my response on the excellent response of Robert Kozak, even though I don't quite use my logging the same way
I use five types of log statements:
- DEBUG
- INFO
- WARNING
- ERROR
- FATAL
DEBUG?statements are statements which are useful when you are still writing an application, and when you need a complete understanding of what/where your execution flow is. You can use DEBUG statements to measure the queue in front of a lock, or check usernames of users logging in, or even the parameters for a certain SQL call that's been troubling. DEBUG is for statements which are not generally needed to be known.
INFO?should be used whenever there is information which will be very useful if something goes wrong, but does not indicate that anything has gone wrong. If you use too many INFO statements, your logs will become bloated and unuseful, so be careful. Use INFO for any critical information which you will need on error, and it is no where near where the error will be throw.
Use?WARN?level if you have detected a recoverable, but still unexpected (at least a little expected, because you caught it). It indicates that your application MAY be in an unworkable state, but that you believe you can recover/continue on the current execution path.
ERROR?warnings are for whenever you catch an unexpected exception. If you are recovering/retrying the current method, I'd suggest using WARN. If you are canceling/bailing out, use the ERROR. Even if your program can continue, ERROR means that you were attempting to do something and were rejected, and are therefore moving on to other things.
FATAL?is for use when you catch something at a level far beneath where it was thrown, and you essentially have no idea what's going on. It means you are not even attempting to continue execution, you are simply going to log every possible bit of information at your disposal and then try to exit gracefully. FATAL errors are infrequently used because generally if you catch an error, you have enough information to try and continue execution. But in the scenarios where corruption might occur if you try and continue, log a FATAL error, and then run away.
?
?
As for where you're logging to. I usually like to log to a 'shared' folder on my app servers (be careful about permissioning so that they are not public) so that the logs are very easily accessible and they are always my first step for debugging. If possible, set it up so that any errors that are WARNING, ERROR, or FATAL are sent out by email so that you'll have 'advanced' warning.
?
2. Log 不僅可以用文本,DB的形式存儲,還可以發布到Web??蓞⒖挤桨?Apache Chainsaw,?log4net Dashboard
?
轉載于:https://www.cnblogs.com/ssjzhong/p/4650635.html
總結
以上是生活随笔為你收集整理的关于Log 的一些东西的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 外贸上fob是什么意思(外贸中FOB是什
- 下一篇: [异能程序员]第五章 出手(第一更)