We saw in my previous blog that SLF4J and SimpleLogger support the most critical logging requirements with ease. In this blog, we will see how to use SLF4J in a Servlets based application. The general practice is to initialize logging related objects and parameters at the startup of an application. In case of Servlets, any of the servlet in the Web Application can be invoked due to user action. So we need to use a different technique for initializing logging related objects.
If you write networking or IO oriented programs using Java, there will be several situations where the code on the server will catch multiple exceptions. Most of the times the exceptions are logged, sometimes they are logged and re-thrown.