21 Aralık 2011 Çarşamba

log4j NDC

Here is a link about logging best practices:  http://c2.com/cgi/wiki?LoggingBestPractices
The last rule of thumb:
If you're logging the output of a web service or something like that, make sure you log an item which is unique to the session in each log message. With log4j, you can do this using a NDC. (We didn't use the session id, thats too long, we grabbed a unique integer and put it into the session). This way you can trace whats happening to a single session very easily. You can also log the request parameters as well if you're concerned about that sort of thing

for code sample:

public ReturnType method( InputType input) throws ExceptionType{

      try {
         // do something
      } catch(ExceptionType e) {
         throw e;
      } finally {

Hiç yorum yok:

Yorum Gönder