tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: How can I access tomcat's logs using my jsp?
Date Fri, 03 Feb 2012 21:21:24 GMT
Terence M. Bandoian wrote:
>  On 1:59 PM, Lev A KARATUN wrote:
>> Hello!
>>
>> I'm administering an application running on Tomcat 6.0.0.29. OS is AIX
>> 5.3.
>>
>> I'm trying to write a simple jsp to make some superusers able to download
>> tomcat logs via browser after entering a password. (In my organization
>> it's not permitted to give anyone the "manager" role)
>> I've already managed to get a list log-files' names (just copied 
>> someone's
>> part of code and made some adjustments), but when I'm trying to make
>> download links, I don't know how can I specify the path to
>> /$CATALINA_BASE/logs via my web-browser. As far as I can see, I can reach
>> only folders like /$CATALINA_BASE/webapps/myapp upon entering the link
>> http://myhost:port/myapp.
>>
>> So, the question is - how can I access tomcat's logs using my jsp?
>>
>>
>> Thanks in advance.
>>
>> Best Regards,
>> Karatun Lev
> 
> Hi, Karatun-
> 
> What about providing links like 'download_log.jsp?log=catalina.log' and 
> then, in download_log.jsp, copying the requested file to the response 
> output stream?  Security would be a consideration but not really a big 
> problem.
> 

Building on a earlier response by Pid,

- you can create a webapp named "tomcat-logs" (or whatever), just by creating a new 
directory "tomcat-logs" (or whatever) under webapps.
- to protect access to it, you'll need a WEB-INF/web.xml, with some security/auth 
constraints, just like any other protected application.
- you will need a META-INF/context.xml, specifying as docBase, the directory where the 
logs really are.
- and you will need to specify somewhere, that for this directory, Tomcat is allowed to 
generate a page with an index to the files. I forget how that's done, but it is probably a

tag in web.xml also.

You don't even need a JSP or a servlet.  By default, Tomcat will serve the content of the

docBase using the default servlet. Your logs are files, just like static html pages are.

When someone asks for the URL /tomcat-logs
  1) they will have to login
  2) they will then get a directory listing
  3) by clicking on a link, they will get the content of the file in their browser window

(which may not be such a good idea, as this may be a lot of lines; but since they are 
administrators, they should know what they are doing)
  4) when right-clicking on any of the links, they will be able to download the file

That is essentially what you want, no ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message