|
Hi, I'm currently maintaining a system which is written in JSP and using Java. It has no framework, therefore, some of the business logics are in JSP which is a presentation layer. I'm planning to use Log4J for our logging, but unfortunately, the Logger class needs to have a class as one of the parameters. The common code for this is Logger log = Logger.getLogger(YourClass.class); Example, I have a logger util class LoggerTest:
And then I used this inside JSP
As you would notice, the The problem is, when this is used in JSP, I am having a nullpointer exception, because obviously, JSP is not a class. I'm not sure now if we can use Log4J with JSP. Tablibs on the other hand has already resigned and I think has been deprecated since 2002. Aside from the Any questions or comments will be appreciated. Thanks! :)
This question is marked "community wiki".
|
|
I therefore conclude that this is still possible. I missed out the right syntax. Instead of the above code in JSP, it should be:
The |
|
Why not just use Logger.getLogger(String) instead of going through hoops?
|
|
i think it is not advisable to log messages while on the jsp pages because jsp is just used to display html pages to the user. It is better for you to log messages on the controller. try to use SimpleMappingExceptionResolver. it is very helpful for me in logging and displaying error messages in a JSP page. |