• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Logging in JSP - Log4j  RSS feed

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use Logging in JSP pages.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ page import="org.apache.log4j.Logger" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%

Logger log1=Logger.getLogger(this.getClass());

log1.info("Information");
log1.debug("Hello");
%>
<%= new String("Hello") %>

<% %>
</body>
</html>

Still I dont see any error . I dont see log file also getting generated. Can you please help?
 
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, logging should not be necessary in a JSP as a modern JSP should contain no Java code.

That said, how did you enable the debug level for the logger?
 
Madhumitha Baskaran
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

log4j.rootCategory=debug,stdout1

# A1 is set to be a LF5Appender which outputs to a swing
# logging console.

log4j.appender.stdout1=org.apache.log4j.FileAppender
log4j.appender.stdout1.File=SampleLogFile
log4j.appender.stdout1.layout=org.apache.log4j.PatternLayout

This is how I had log4j file.

My primary intent of using log file is to track all the activities happening in a web page. What would you suggest for that?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I wouldn't. Activities that are interesting enough to log should be happening in the controller, rather than the JSP.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!