Dark Matter
Dark Matter

Reputation: 2311

Issue with logging in JSP page

I want to use looging from a jsp page and I have initialised the loggger as shown.

Logger logger = Logger.getLogger( "sample.jsp" );

But when I try to log any startements as logger.log("Sample Output");, its giving me the following exception.

The method log(String, Priority, Object, Throwable) in the type Category is not applicable for the arguments (String)

Why is this error occurring and how can I solve the same.

Upvotes: 0

Views: 516

Answers (3)

Omar.Nassar
Omar.Nassar

Reputation: 379

Call info(), debug(), error(),.. instead of log()

Upvotes: 2

lol
lol

Reputation: 3390

Because there is no such method.

Use more appropriate methods like: fatal(), error(), info(), debug() etc.

Check documentation here:

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

The error says, method expects these arguments:

log(String, Priority, Object, Throwable)

But you are passing only String.

Upvotes: 4

Prabha
Prabha

Reputation: 705

Use below code in your JSP

<% Logger logger=Logger.getLogger(this.getClass().getName());%>

Upvotes: 0

Related Questions