tags:

views:

312

answers:

1

Whats the best way to add log4j logging to a jsp tag file.. I've got as far as importing the logger class..

<%@ tag import="org.apache.log4j.Logger" %>

But having a bit of trouble initialising the logger object.

<% Logger log = Logger.getLogger("xxx.xxx.xxx.xx"); %>

Because I'm using a tag file with a .tag extension, what do I put is as the class reference to it in the getLogger method call above?

I don't fancy pluging in the log4j taglib at this stage.

Thanks for looking.

+1  A: 

You don't have to use a class in the call to get getLogger. You can just pass in any string that acts as an identifier for the Logger instance you're getting back. See the docs here:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

You can just pass in any identifier (i.e. "jsp.tag.MyTagName") but it's not going to include the calling tag or anything fancy like that unless your tag supports passing in some sort of identifier to append on to the Logger name.

SystemOut