Can i use log4j in jsp file? How to initialize the registrar in jsp?

I want to use the log4j framework in a jsp file.

Typical log4j initialization in a java file:

Logger log = Logger.getLogger (loggedin.class);

How to initialize logger in jsp file? It can be done?

+4
source share
2 answers

you could say <%Logger LOG= Logger.getLogger(getclass());%> , this will create a logger for the jsp class created.

+5
source

In general, JSP logging is not recommended. But if you really want to do this, try this,

Logger log = Logger.getLogger ("loggedin.jsp");

Assuming the JSP file name is loggedin.jsp, but you can specify any meaningful name to distinguish the log data.

+1
source

All Articles