I have a doubt regarding use of log4j and layers. eg: I have a DAO class that uses jdbc to get data from db. When a error happen, it calls logger.error, and throws a new exception (DAOException, for exemple), which is catch by the servlet, that in the same way calls for looger.error and redirects to an error page (with a error id to map to the log file). The logger call in DAO puts the sql string executed in the log message, as the logger cal at the servlet just knows it was a db error and the error id.
My question : would be it better not call logger in the lower level (DAO class in the case) and let the servlet log all the errors? so I would pass the entire string of sql when creating the new excpetion (and passing the first exception, what would appear as the root exception?). The problem is that in case of error, a lot of error logs entries would appear, what could be a kind of confusion. In the approache i just suggest, i would have a single entry, with the sql code, and the error id (it's a time stamp).
I'm trying to find a good pattern to use log4j in my apps.


Thanks in advance

--
Emerson Cargnin
Analista de Sitemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to