A simple example of log4j for Servlet
This Example shows you how to create a log in a Servlet.Description of the code:
Logger.getLogger(): Logger class is used for handling the majority of log operations and getLogger method is used for return a logger according to the value of the parameter. If the logger already exists, then the existing instance will be returned. If the logger is not already exist, then create a new instance.
log.info(): This method is used to check that the specified category is INFO enabled or not, if yes then it converts the massage passed as a string argument to a string by using appropriate object renderer of class ObjectRenderer.
LoggingServlet :
HttpServletResponse response)
|
Output:
Download code