Hi,

I've written several servlets that present log-information to the 
browser. Getting the file, filter and put it out in html is a piece
of cake (do not forget to filter out html-characters like < and >...).
The biggest problem normally is to get to know where the log-files are 
and what name they have.
Servlet-specs allow you to specify parameters in the servlet-definition
(init-param). So when you setup web.xml you can pass these informations
(path and file-names) to the servlet. Or you could specify path and 
file-names in the startup script of the servlet-container (-Dparmname=value).
System-properties can be read from servlets too.

So basically you just need to isolate the file-access (servlet, standard 
java-io) from the location-info (path, file-name -> container-specific)
and then you are done with your requirements.

Alternatively:
use a logging-mechanism (JDK-1.3-logging, log4j,...) to set up a logger
that you can use also outside the servlet-class (modell-layer). That
mechanism must also be configured (log-persistance, locations...). The
same info can be passed to the servlet (again the same mechanism as above).
Or you can establish a helper-class that gives access to the logger and 
some of its setup-info...
eg.
class needing to log: LogHelper.getInstance().log(message);
servlet showing log: LogHelper.getInstance().getLogLocation();

hope you get the idea (else ask and try to explain better)
Alexander

-----Original Message-----
From: Jonathan Fuerth [mailto:[EMAIL PROTECTED]]
Sent: Donnerstag, 4. Juli 2002 23:45
To: [EMAIL PROTECTED]
Subject: Per-user downloadable logs


We are looking at various user-support scenarios for our Struts-based
webapp.  What we're aiming for is to create a Struts action that will
return a (plain text) log of the current user's actions over a
specified time interval, which they can then attach to an email when
they have product support questions.

We aren't willing to tie the application to a specific servlet
container (such as Tomcat or WebLogic), so anything we do will have to
work with Struts-1.1(b1) and the Servlet-2.2 specification.

So it would seem that using ServletContext.log() is out, since there's
no vendor-independant way of getting at the log from within the webapp
(and I don't see anything in the spec about the format of those log
entries either).

Going to an extremely custom solution (like writing a log4j appender
that inserts into a database table which our "log retrieval" action
could then query) is a possibility, but it has drawbacks: It adds lots
of insert activity to what is now pretty much a query-only
application; it adds another table to our database schema;
database-connectivity related problems can't be logged.

How have other struts users solved the problem of getting at the
application logs without needing to involve the web administrator?
I'd be grateful for any hints or pointers to solutions!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to