You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lev A KARATUN <Le...@raiffeisen.ru> on 2012/02/03 14:53:52 UTC

How can I access tomcat's logs using my jsp?

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


-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by Pid <pi...@pidster.com>.
On 03/02/2012 13:53, 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)

So give them a different role and change the rolename in the app web.xml.

> 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?

Are you intending to allow download for logs in the same application
server or a different one?  I'd be wary about the security issues here.

You can use a Servlet to forward a request to another resource.

Or you can map a docBase to another directory.


p


> Thanks in advance.
> 
> Best Regards, 
> Karatun Lev
> 
> 
> -----------------------------------
> This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
> -----------------------------------


-- 

[key:62590808]


Re: How can I access tomcat's logs using my jsp?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 2/3/12 5:47 PM, André Warnier wrote:
> Caldarale, Charles R wrote:
>>> From: André Warnier [mailto:aw@ice-sa.com] Subject: Re: How can
>>> I access tomcat's logs using my jsp?
>> 
>>> - you can create a webapp named "tomcat-logs" (or whatever),
>>> just by creating a new directory "tomcat-logs" (or whatever)
>>> under webapps.
>> 
>> Nope.
> Here I beg to differ. The statement above was entirely accurate. 
> This application won't do anything, and even less what the OP
> wanted, but it will exist, and Tomcat will dispatch to it.

Yes, but it won't serve the files you want. It will most likely serve
an empty directory (or it should). Tomcat will ignore the docBase (or
it should).

You might be able to use a VirtualWebappLoader with the virtual class
path set to ${catalina.base}/logs, but I'm not sure if the
DefaultServlet will be able to use that. I've never tried it.

Or, you could just write some code to read and dump the file(s)
yourself. I would probably have specific log file names that are
recognized and served rather than allowing the remote user to just
specify a filename and let them poke-around looking for whatever files
your webapp is willing to serve. Just ask for ../conf/server.xml and
we've got a problem unless you're very careful about sanitizing inputs.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8tdZEACgkQ9CaO5/Lv0PDWyACeOWGjjgbzo0xxDOj/GzCBKuk1
9e4AoLhRqpnzTG6oeFSvbpRDJLAdNqsk
=zbVt
-----END PGP SIGNATURE-----

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


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
>> From: André Warnier [mailto:aw@ice-sa.com] 
>> Subject: Re: How can I access tomcat's logs using my jsp?
> 
>> - you can create a webapp named "tomcat-logs" (or whatever), just by 
>> creating a new directory "tomcat-logs" (or whatever) under webapps.
> 
> Nope.
Here I beg to differ. The statement above was entirely accurate.
This application won't do anything, and even less what the OP wanted,
but it will exist, and Tomcat will dispatch to it.

> 
>> - to protect access to it, you'll need a WEB-INF/web.xml, with some 
>> security/auth constraints, just like any other protected application.
> 
> That is needed.  However, this WEB-INF directory and consequently the WEB-INF/web.xml file must be placed in Tomcat's log directory.
> 
>> - you will need a META-INF/context.xml, specifying as docBase, the 
>> directory where the logs really are.
> 
> Nope, that won't work; docBase is not allowed when the webapp is inside the <Host> appBase directory.  The <Context> element must be placed in conf/Catalina/[hostName]/[appName].xml, with the docBase pointing to the location of the logs directory.
> 
>> - and you will need to specify somewhere, that for this directory, 
>> Tomcat is allowed to generate a page with an index to the files.
> 
> That's done by enabling the listings parameter for the DefaultServlet.  The OP will need to copy the <servlet> tag and its sub-tags for the DefaultServlet from conf/web.xml to the log webapp's WEB-INF/web.xml and set the listings parameter to true.  You do not want to enable the listings parameter in the global conf/web.xml for what should be obvious reasons.
>  

Thanks for rectifying my sloppy suggestions and providing the accurate instructions.
In my defense, I will argue that my suggestions were made with good intentions, that at 
least the general idea was fine, and I will thus beg for the forgiveness of the court.


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


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
> Pid wrote:
>> On 07/02/2012 09:07, André Warnier wrote:
>>> For once, it may be best to top-post.
>>>
>>> Anyone feels like making a FAQ out of this thread ?
>>> It looks like a generic-enough question and answer.
>>
>> I don't think I want to encourage publishing logs via the same
>> container.  I've seen all sorts of private data published in log files.
>>
> I wasn't talking about "logs" per se (I agree on that one).
> What I meant was more like :
> 
> How-To : create a simple "webapp" which publishes the content of an 
> arbitrary directory containing static documents, without having to write 
> a special-purpose JSP page or servlet, and without compromising security.
> 
> At the same time, it is almost a book-perfect example of what can be 
> done with the normal webapp deployment rules, where to put a context 
> file, what the default servlet does, etc..
> 
> 
Now one more question about this :
Suppose someone follows exactly the steps outlined by Chuck before.
And then suppose that through the Manager, one triggers an "un-deploy" of this application.
Will Tomcat then delete all the files inside that directory ?
And if yes, is there a way to prevent that ?

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


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
Pid wrote:
> On 07/02/2012 09:07, André Warnier wrote:
>> For once, it may be best to top-post.
>>
>> Anyone feels like making a FAQ out of this thread ?
>> It looks like a generic-enough question and answer.
> 
> I don't think I want to encourage publishing logs via the same
> container.  I've seen all sorts of private data published in log files.
> 
I wasn't talking about "logs" per se (I agree on that one).
What I meant was more like :

How-To : create a simple "webapp" which publishes the content of an arbitrary directory 
containing static documents, without having to write a special-purpose JSP page or 
servlet, and without compromising security.

At the same time, it is almost a book-perfect example of what can be done with the normal 
webapp deployment rules, where to put a context file, what the default servlet does, etc..



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


Re: How can I access tomcat's logs using my jsp?

Posted by Pid <pi...@pidster.com>.
On 07/02/2012 09:07, André Warnier wrote:
> For once, it may be best to top-post.
> 
> Anyone feels like making a FAQ out of this thread ?
> It looks like a generic-enough question and answer.

I don't think I want to encourage publishing logs via the same
container.  I've seen all sorts of private data published in log files.


p

> Lev A KARATUN wrote:
>> Charles,
>>
>> I made the adjustments and it works now.
>>
>> Thank you!
>>
>> Best Regards, Karatun Lev,
>>
>>
>> "Caldarale, Charles R" <Ch...@unisys.com> wrote on
>> 06.02.2012 18:41:18:
>>
>>> "Caldarale, Charles R" <Ch...@unisys.com> 06.02.2012 18:42
>>>
>>> Please respond to
>>> "Tomcat Users List" <us...@tomcat.apache.org>
>>>
>>> To
>>>
>>> Tomcat Users List <us...@tomcat.apache.org>
>>>
>>> cc
>>>
>>> Subject
>>>
>>> RE: How can I access tomcat's logs using my jsp?
>>>
>>>> From: Lev A KARATUN [mailto:Lev.KARATUN@raiffeisen.ru] Subject: RE:
>>>> How can I access tomcat's logs using my jsp?
>>>> when I'm copypasting the default servlet block to
>>>> $CATALINA_BASE/logs/WEB-INF/web.xml, the application
>>>> no longer works.
>>> There's an additional step required for Tomcat 6 that's not necessary
>>> for Tomcat 7.  So either upgrade, or do the following:
>>>
>>> Change the name of the DefaultServlet in logs/WEB-INF/web.xml to
>>> logsdefault (or some other unique label):
>>>
>>>         <servlet-name>logsdefault</servlet-name>
>>>
>>> and add a <servlet-mapping> for it:
>>>
>>>     <servlet-mapping>
>>>         <servlet-name>logsdefault</servlet-name>
>>>         <url-pattern>/</url-pattern>
>>>     </servlet-mapping>
>>>
>>> Tomcat 6 does not allow you to override the <servlet-name> settings
>>> in the global conf/web.xml, but Tomcat 7 does.
>>>
>>>> And one more question - if myapp's docBase is set to 
>> $CATALINA_BASE/logs ,
>>>> does it matter what is in the webapps/myapp folder?
>>> Assuming the "myapp" you're referring to is the one for accessing
>>> Tomcat's logs, you should not risk problems by also having a
>>> webapps/myapp.  It shouldn't hurt, but...
>>>
>>> And, as usual, ignore Martin G's irrelevant ramblings.
>>>
>>>  - Chuck
>>>
>>>
>>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
>>> PROPRIETARY MATERIAL and is thus for use only by the intended
>>> recipient. If you received this in error, please contact the sender
>>> and delete the e-mail and its attachments from all computers.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>>
>> -----------------------------------
>> This message and any attachment are confidential and may be privileged
>> or otherwise protected from disclosure. If you are not the intended
>> recipient any use, distribution, copying or disclosure is strictly
>> prohibited. If you have received this message in error, please notify
>> the sender immediately either by telephone or by e-mail and delete
>> this message and any attachment from your system. Correspondence via
>> e-mail is for information purposes only. ZAO Raiffeisenbank neither
>> makes nor accepts legally binding statements by e-mail unless
>> otherwise agreed. -----------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


-- 

[key:62590808]


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
For once, it may be best to top-post.

Anyone feels like making a FAQ out of this thread ?
It looks like a generic-enough question and answer.



Lev A KARATUN wrote:
> Charles,
> 
> I made the adjustments and it works now.
> 
> Thank you!
> 
> Best Regards, 
> Karatun Lev,
> 
> 
> "Caldarale, Charles R" <Ch...@unisys.com> wrote on 06.02.2012 
> 18:41:18:
> 
>> "Caldarale, Charles R" <Ch...@unisys.com> 
>> 06.02.2012 18:42
>>
>> Please respond to
>> "Tomcat Users List" <us...@tomcat.apache.org>
>>
>> To
>>
>> Tomcat Users List <us...@tomcat.apache.org>
>>
>> cc
>>
>> Subject
>>
>> RE: How can I access tomcat's logs using my jsp?
>>
>>> From: Lev A KARATUN [mailto:Lev.KARATUN@raiffeisen.ru] 
>>> Subject: RE: How can I access tomcat's logs using my jsp?
>>> when I'm copypasting the default servlet block to 
>>> $CATALINA_BASE/logs/WEB-INF/web.xml, the application
>>> no longer works.
>> There's an additional step required for Tomcat 6 that's not 
>> necessary for Tomcat 7.  So either upgrade, or do the following:
>>
>> Change the name of the DefaultServlet in logs/WEB-INF/web.xml to 
>> logsdefault (or some other unique label):
>>
>>         <servlet-name>logsdefault</servlet-name>
>>
>> and add a <servlet-mapping> for it:
>>
>>     <servlet-mapping>
>>         <servlet-name>logsdefault</servlet-name>
>>         <url-pattern>/</url-pattern>
>>     </servlet-mapping>
>>
>> Tomcat 6 does not allow you to override the <servlet-name> settings 
>> in the global conf/web.xml, but Tomcat 7 does.
>>
>>> And one more question - if myapp's docBase is set to 
> $CATALINA_BASE/logs , 
>>> does it matter what is in the webapps/myapp folder?
>> Assuming the "myapp" you're referring to is the one for accessing 
>> Tomcat's logs, you should not risk problems by also having a 
>> webapps/myapp.  It shouldn't hurt, but...
>>
>> And, as usual, ignore Martin G's irrelevant ramblings.
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
>> PROPRIETARY MATERIAL and is thus for use only by the intended 
>> recipient. If you received this in error, please contact the sender 
>> and delete the e-mail and its attachments from all computers.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> 
> 
> -----------------------------------
> This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
> -----------------------------------


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


RE: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
Charles,

I made the adjustments and it works now.

Thank you!

Best Regards, 
Karatun Lev,


"Caldarale, Charles R" <Ch...@unisys.com> wrote on 06.02.2012 
18:41:18:

> "Caldarale, Charles R" <Ch...@unisys.com> 
> 06.02.2012 18:42
> 
> Please respond to
> "Tomcat Users List" <us...@tomcat.apache.org>
> 
> To
> 
> Tomcat Users List <us...@tomcat.apache.org>
> 
> cc
> 
> Subject
> 
> RE: How can I access tomcat's logs using my jsp?
> 
> > From: Lev A KARATUN [mailto:Lev.KARATUN@raiffeisen.ru] 
> > Subject: RE: How can I access tomcat's logs using my jsp?
> 
> > when I'm copypasting the default servlet block to 
> > $CATALINA_BASE/logs/WEB-INF/web.xml, the application
> > no longer works.
> 
> There's an additional step required for Tomcat 6 that's not 
> necessary for Tomcat 7.  So either upgrade, or do the following:
> 
> Change the name of the DefaultServlet in logs/WEB-INF/web.xml to 
> logsdefault (or some other unique label):
> 
>         <servlet-name>logsdefault</servlet-name>
> 
> and add a <servlet-mapping> for it:
> 
>     <servlet-mapping>
>         <servlet-name>logsdefault</servlet-name>
>         <url-pattern>/</url-pattern>
>     </servlet-mapping>
> 
> Tomcat 6 does not allow you to override the <servlet-name> settings 
> in the global conf/web.xml, but Tomcat 7 does.
> 
> > And one more question - if myapp's docBase is set to 
$CATALINA_BASE/logs , 
> > does it matter what is in the webapps/myapp folder?
> 
> Assuming the "myapp" you're referring to is the one for accessing 
> Tomcat's logs, you should not risk problems by also having a 
> webapps/myapp.  It shouldn't hurt, but...
> 
> And, as usual, ignore Martin G's irrelevant ramblings.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
> PROPRIETARY MATERIAL and is thus for use only by the intended 
> recipient. If you received this in error, please contact the sender 
> and delete the e-mail and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

RE: How can I access tomcat's logs using my jsp?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Lev A KARATUN [mailto:Lev.KARATUN@raiffeisen.ru] 
> Subject: RE: How can I access tomcat's logs using my jsp?

> when I'm copypasting the default servlet block to 
> $CATALINA_BASE/logs/WEB-INF/web.xml, the application
> no longer works.

There's an additional step required for Tomcat 6 that's not necessary for Tomcat 7.  So either upgrade, or do the following:

Change the name of the DefaultServlet in logs/WEB-INF/web.xml to logsdefault (or some other unique label):

        <servlet-name>logsdefault</servlet-name>

and add a <servlet-mapping> for it:

    <servlet-mapping>
        <servlet-name>logsdefault</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

Tomcat 6 does not allow you to override the <servlet-name> settings in the global conf/web.xml, but Tomcat 7 does.

> And one more question - if myapp's docBase is set to $CATALINA_BASE/logs , 
> does it matter what is in the webapps/myapp folder?

Assuming the "myapp" you're referring to is the one for accessing Tomcat's logs, you should not risk problems by also having a webapps/myapp.  It shouldn't hurt, but...

And, as usual, ignore Martin G's irrelevant ramblings.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: How can I access tomcat's logs using my jsp?

Posted by Pid <pi...@pidster.com>.
On 06/02/2012 13:14, André Warnier wrote:
> Pid wrote:
>> On 06/02/2012 11:53, Lev A KARATUN wrote:
>>
>>> And one more question - if myapp's docBase is set to
>>> $CATALINA_BASE/logs , does it matter what is in the webapps/myapp
>>> folder?
>>
>> No.
>>
> Wait..
> If the myapp application is deployed via a context file under
> conf/Catalina/[hostName]/myapp.xml
> AND there exists a webapps/myapp directory,
> isn't that going to cause a double deployment ?

Not if the paths of the context xml file and the application directory
are the same.  The context defined in tomcat/conf/Catalina/host takes
precedence.


p


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


-- 

[key:62590808]


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
Pid wrote:
> On 06/02/2012 11:53, Lev A KARATUN wrote:
> 
>> And one more question - if myapp's docBase is set to $CATALINA_BASE/logs , 
>> does it matter what is in the webapps/myapp folder?
> 
> No.
> 
Wait..
If the myapp application is deployed via a context file under 
conf/Catalina/[hostName]/myapp.xml
AND there exists a webapps/myapp directory,
isn't that going to cause a double deployment ?


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


Re: How can I access tomcat's logs using my jsp?

Posted by Pid <pi...@pidster.com>.
On 06/02/2012 11:53, Lev A KARATUN wrote:
> Charles,
> 
> thank for your explanation.
> 
> Now everything (exept one thing) seems to work fine.
> 
> The only problem left is - when I'm copypasting the default servlet block 
> to $CATALINA_BASE/logs/WEB-INF/web.xml , the application no longer works.

What are the other symptoms?  Log messages, etc?

> Without it everything works fine (but I can't disable the directory 
> listings general setting because I need it swithed on for the /logs dir).
> 
> The block that I copy is :
> 
>     <servlet>
>         <servlet-name>default</servlet-name>
>  
> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
>         <init-param>
>             <param-name>debug</param-name>
>             <param-value>0</param-value>
>         </init-param>
>         <init-param>
>             <param-name>listings</param-name>
>             <param-value>true</param-value>
>         </init-param>
>         <load-on-startup>1</load-on-startup>
>     </servlet> 
> 
> (I place it inside the <web-app> section)

Have you also copied the servlet-mapping block?

> And one more question - if myapp's docBase is set to $CATALINA_BASE/logs , 
> does it matter what is in the webapps/myapp folder?

No.


p

> Thanks in advance.
> 
> 
> "Caldarale, Charles R" <Ch...@unisys.com> wrote on 04.02.2012 
> 01:44:08:
> 
>> "Caldarale, Charles R" <Ch...@unisys.com> 
>> 04.02.2012 01:45
>>
>> Please respond to
>> "Tomcat Users List" <us...@tomcat.apache.org>
>>
>> To
>>
>> Tomcat Users List <us...@tomcat.apache.org>
>>
>> cc
>>
>> Subject
>>
>> RE: How can I access tomcat's logs using my jsp?
>>
>>> From: André Warnier [mailto:aw@ice-sa.com] 
>>> Subject: Re: How can I access tomcat's logs using my jsp?
>>
>>> - you can create a webapp named "tomcat-logs" (or whatever), just by 
>>> creating a new directory "tomcat-logs" (or whatever) under webapps.
>>
>> Nope.
>>
>>> - to protect access to it, you'll need a WEB-INF/web.xml, with some 
>>> security/auth constraints, just like any other protected application.
>>
>> That is needed.  However, this WEB-INF directory and consequently 
>> the WEB-INF/web.xml file must be placed in Tomcat's log directory.
>>
>>> - you will need a META-INF/context.xml, specifying as docBase, the 
>>> directory where the logs really are.
>>
>> Nope, that won't work; docBase is not allowed when the webapp is 
>> inside the <Host> appBase directory.  The <Context> element must be 
>> placed in conf/Catalina/[hostName]/[appName].xml, with the docBase 
>> pointing to the location of the logs directory.
>>
>>> - and you will need to specify somewhere, that for this directory, 
>>> Tomcat is allowed to generate a page with an index to the files.
>>
>> That's done by enabling the listings parameter for the 
>> DefaultServlet.  The OP will need to copy the <servlet> tag and its 
>> sub-tags for the DefaultServlet from conf/web.xml to the log 
>> webapp's WEB-INF/web.xml and set the listings parameter to true. 
>> You do not want to enable the listings parameter in the global conf/
>> web.xml for what should be obvious reasons.
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
>> PROPRIETARY MATERIAL and is thus for use only by the intended 
>> recipient. If you received this in error, please contact the sender 
>> and delete the e-mail and its attachments from all computers.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> 
> 
> -----------------------------------
> This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
> -----------------------------------


-- 

[key:62590808]


RE: How can I access tomcat's logs using my jsp?

Posted by Martin Gainty <mg...@hotmail.com>.
The catalina logger has exclusive access for writing but
you can try RandomAccessFile with read only mode for a quick peek at the loghttp://docs.oracle.com/javase/6/docs/api/java/io/RandomAccessFile.html#RandomAccessFile(java.io.File, java.lang.String) Saludos Cordiales
Martin 
______________________________________________ 
Porfavor..no altere esta communicacion..Gracias

 > To: users@tomcat.apache.org
> Subject: RE: How can I access tomcat's logs using my jsp?
> From: Lev.KARATUN@raiffeisen.ru
> Date: Mon, 6 Feb 2012 15:53:11 +0400
> 
> Charles,
> 
> thank for your explanation.
> 
> Now everything (exept one thing) seems to work fine.
> 
> The only problem left is - when I'm copypasting the default servlet block 
> to $CATALINA_BASE/logs/WEB-INF/web.xml , the application no longer works.
> Without it everything works fine (but I can't disable the directory 
> listings general setting because I need it swithed on for the /logs dir).
> 
> The block that I copy is :
> 
>     <servlet>
>         <servlet-name>default</servlet-name>
>  
> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
>         <init-param>
>             <param-name>debug</param-name>
>             <param-value>0</param-value>
>         </init-param>
>         <init-param>
>             <param-name>listings</param-name>
>             <param-value>true</param-value>
>         </init-param>
>         <load-on-startup>1</load-on-startup>
>     </servlet> 
> 
> (I place it inside the <web-app> section)
> 
> 
> And one more question - if myapp's docBase is set to $CATALINA_BASE/logs , 
> does it matter what is in the webapps/myapp folder?
> 
> 
> Thanks in advance.
> 
> 
> "Caldarale, Charles R" <Ch...@unisys.com> wrote on 04.02.2012 
> 01:44:08:
> 
> > "Caldarale, Charles R" <Ch...@unisys.com> 
> > 04.02.2012 01:45
> > 
> > Please respond to
> > "Tomcat Users List" <us...@tomcat.apache.org>
> > 
> > To
> > 
> > Tomcat Users List <us...@tomcat.apache.org>
> > 
> > cc
> > 
> > Subject
> > 
> > RE: How can I access tomcat's logs using my jsp?
> > 
> > > From: André Warnier [mailto:aw@ice-sa.com] 
> > > Subject: Re: How can I access tomcat's logs using my jsp?
> > 
> > > - you can create a webapp named "tomcat-logs" (or whatever), just by 
> > > creating a new directory "tomcat-logs" (or whatever) under webapps.
> > 
> > Nope.
> > 
> > > - to protect access to it, you'll need a WEB-INF/web.xml, with some 
> > > security/auth constraints, just like any other protected application.
> > 
> > That is needed.  However, this WEB-INF directory and consequently 
> > the WEB-INF/web.xml file must be placed in Tomcat's log directory.
> > 
> > > - you will need a META-INF/context.xml, specifying as docBase, the 
> > > directory where the logs really are.
> > 
> > Nope, that won't work; docBase is not allowed when the webapp is 
> > inside the <Host> appBase directory.  The <Context> element must be 
> > placed in conf/Catalina/[hostName]/[appName].xml, with the docBase 
> > pointing to the location of the logs directory.
> > 
> > > - and you will need to specify somewhere, that for this directory, 
> > > Tomcat is allowed to generate a page with an index to the files.
> > 
> > That's done by enabling the listings parameter for the 
> > DefaultServlet.  The OP will need to copy the <servlet> tag and its 
> > sub-tags for the DefaultServlet from conf/web.xml to the log 
> > webapp's WEB-INF/web.xml and set the listings parameter to true. 
> > You do not want to enable the listings parameter in the global conf/
> > web.xml for what should be obvious reasons.
> > 
> >  - Chuck
> > 
> > 
> > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
> > PROPRIETARY MATERIAL and is thus for use only by the intended 
> > recipient. If you received this in error, please contact the sender 
> > and delete the e-mail and its attachments from all computers.
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
> 
> 
> 
> -----------------------------------
> This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
> -----------------------------------
 		 	   		  

RE: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
Charles,

thank for your explanation.

Now everything (exept one thing) seems to work fine.

The only problem left is - when I'm copypasting the default servlet block 
to $CATALINA_BASE/logs/WEB-INF/web.xml , the application no longer works.
Without it everything works fine (but I can't disable the directory 
listings general setting because I need it swithed on for the /logs dir).

The block that I copy is :

    <servlet>
        <servlet-name>default</servlet-name>
 
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet> 

(I place it inside the <web-app> section)


And one more question - if myapp's docBase is set to $CATALINA_BASE/logs , 
does it matter what is in the webapps/myapp folder?


Thanks in advance.


"Caldarale, Charles R" <Ch...@unisys.com> wrote on 04.02.2012 
01:44:08:

> "Caldarale, Charles R" <Ch...@unisys.com> 
> 04.02.2012 01:45
> 
> Please respond to
> "Tomcat Users List" <us...@tomcat.apache.org>
> 
> To
> 
> Tomcat Users List <us...@tomcat.apache.org>
> 
> cc
> 
> Subject
> 
> RE: How can I access tomcat's logs using my jsp?
> 
> > From: André Warnier [mailto:aw@ice-sa.com] 
> > Subject: Re: How can I access tomcat's logs using my jsp?
> 
> > - you can create a webapp named "tomcat-logs" (or whatever), just by 
> > creating a new directory "tomcat-logs" (or whatever) under webapps.
> 
> Nope.
> 
> > - to protect access to it, you'll need a WEB-INF/web.xml, with some 
> > security/auth constraints, just like any other protected application.
> 
> That is needed.  However, this WEB-INF directory and consequently 
> the WEB-INF/web.xml file must be placed in Tomcat's log directory.
> 
> > - you will need a META-INF/context.xml, specifying as docBase, the 
> > directory where the logs really are.
> 
> Nope, that won't work; docBase is not allowed when the webapp is 
> inside the <Host> appBase directory.  The <Context> element must be 
> placed in conf/Catalina/[hostName]/[appName].xml, with the docBase 
> pointing to the location of the logs directory.
> 
> > - and you will need to specify somewhere, that for this directory, 
> > Tomcat is allowed to generate a page with an index to the files.
> 
> That's done by enabling the listings parameter for the 
> DefaultServlet.  The OP will need to copy the <servlet> tag and its 
> sub-tags for the DefaultServlet from conf/web.xml to the log 
> webapp's WEB-INF/web.xml and set the listings parameter to true. 
> You do not want to enable the listings parameter in the global conf/
> web.xml for what should be obvious reasons.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
> PROPRIETARY MATERIAL and is thus for use only by the intended 
> recipient. If you received this in error, please contact the sender 
> and delete the e-mail and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by Pid * <pi...@pidster.com>.
On 3 Feb 2012, at 22:47, "André Warnier" <aw...@ice-sa.com> wrote:

> Caldarale, Charles R wrote:
>>> From: André Warnier [mailto:aw@ice-sa.com]
>>> Subject: Re: How can I access tomcat's logs using my jsp?
>>
>>> - you can create a webapp named "tomcat-logs" (or whatever), just by
>>> creating a new directory "tomcat-logs" (or whatever) under webapps.
>>
>> Nope.
> Here I beg to differ. The statement above was entirely accurate.
> This application won't do anything, and even less what the OP wanted,
> but it will exist, and Tomcat will dispatch to it.

Not if the context XML file under Tomcat/conf/<hostname> has a docBase
pointing elsewhere, as you then describe below.


p

>>> - to protect access to it, you'll need a WEB-INF/web.xml, with some
>>> security/auth constraints, just like any other protected application.
>>
>> That is needed.  However, this WEB-INF directory and consequently the WEB-INF/web.xml file must be placed in Tomcat's log directory.
>>
>>> - you will need a META-INF/context.xml, specifying as docBase, the
>>> directory where the logs really are.
>>
>> Nope, that won't work; docBase is not allowed when the webapp is inside the <Host> appBase directory.  The <Context> element must be placed in conf/Catalina/[hostName]/[appName].xml, with the docBase pointing to the location of the logs directory.
>>
>>> - and you will need to specify somewhere, that for this directory,
>>> Tomcat is allowed to generate a page with an index to the files.
>>
>> That's done by enabling the listings parameter for the DefaultServlet.  The OP will need to copy the <servlet> tag and its sub-tags for the DefaultServlet from conf/web.xml to the log webapp's WEB-INF/web.xml and set the listings parameter to true.  You do not want to enable the listings parameter in the global conf/web.xml for what should be obvious reasons.
>>
>
> Thanks for rectifying my sloppy suggestions and providing the accurate instructions.
> In my defense, I will argue that my suggestions were made with good intentions, that at
> least the general idea was fine, and I will thus beg for the forgiveness of the court.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

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


RE: How can I access tomcat's logs using my jsp?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com] 
> Subject: Re: How can I access tomcat's logs using my jsp?

> - you can create a webapp named "tomcat-logs" (or whatever), just by 
> creating a new directory "tomcat-logs" (or whatever) under webapps.

Nope.

> - to protect access to it, you'll need a WEB-INF/web.xml, with some 
> security/auth constraints, just like any other protected application.

That is needed.  However, this WEB-INF directory and consequently the WEB-INF/web.xml file must be placed in Tomcat's log directory.

> - you will need a META-INF/context.xml, specifying as docBase, the 
> directory where the logs really are.

Nope, that won't work; docBase is not allowed when the webapp is inside the <Host> appBase directory.  The <Context> element must be placed in conf/Catalina/[hostName]/[appName].xml, with the docBase pointing to the location of the logs directory.

> - and you will need to specify somewhere, that for this directory, 
> Tomcat is allowed to generate a page with an index to the files.

That's done by enabling the listings parameter for the DefaultServlet.  The OP will need to copy the <servlet> tag and its sub-tags for the DefaultServlet from conf/web.xml to the log webapp's WEB-INF/web.xml and set the listings parameter to true.  You do not want to enable the listings parameter in the global conf/web.xml for what should be obvious reasons.
 
 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
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


Re: How can I access tomcat's logs using my jsp?

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
  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.

-Terence Bandoian


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


Re: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
Christopher, 

actually, I'm new to configuring tomcat and writing .jsp's. All that I 
managed to do up to the moment is - to set up authentication rules and to 
get a jsp that gives me a list of files that I need (in the 
/$catalina_base/my_instance/logs directory). So, I can't give you a sample 
of my code because it doesn't exist yet =)

Thanks for mentioning PsiProbe, I'll try to use it.

Best Regards, 
Karatun Lev,
RBRU IT Application Support ,
(495) 5464



Christopher Schultz <ch...@christopherschultz.net> 
03.02.2012 20:32
Please respond to
"Tomcat Users List" <us...@tomcat.apache.org>


To
Tomcat Users List <us...@tomcat.apache.org>
cc

Subject
Re: How can I access tomcat's logs using my jsp?






-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lev,

On 2/3/12 8:53 AM, Lev A KARATUN wrote:
> 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)

You could bail-out and use a separate utility like PsiProbe which, I
believe, has this kind of thing built right-in.

> 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?

Can you give us a sample of how you are trying to serve the file? Are
you performing a <forward> and trying to let the DefaultServlet serve
the log, or are you reading the file yourself and streaming it back to
the client? I believe only the latter will be possible without
significant alternative configuration.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8sC9cACgkQ9CaO5/Lv0PCKbwCeLt3cUDYf0DjYsF76F9cLVD3s
migAnRHjThUJTyJ0Z2WiiFodz2Zq7GSx
=jWbS
-----END PGP SIGNATURE-----

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





-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lev,

On 2/3/12 8:53 AM, Lev A KARATUN wrote:
> 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)

You could bail-out and use a separate utility like PsiProbe which, I
believe, has this kind of thing built right-in.

> 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?

Can you give us a sample of how you are trying to serve the file? Are
you performing a <forward> and trying to let the DefaultServlet serve
the log, or are you reading the file yourself and streaming it back to
the client? I believe only the latter will be possible without
significant alternative configuration.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8sC9cACgkQ9CaO5/Lv0PCKbwCeLt3cUDYf0DjYsF76F9cLVD3s
migAnRHjThUJTyJ0Z2WiiFodz2Zq7GSx
=jWbS
-----END PGP SIGNATURE-----

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


Re: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
Andre,

thanks for precaution, I'll check the docs.

Best Regards, 
Karatun Lev,
RBRU IT Application Support ,
(495) 5464



André Warnier <aw...@ice-sa.com> 
06.02.2012 12:04
Please respond to
"Tomcat Users List" <us...@tomcat.apache.org>


To
Tomcat Users List <us...@tomcat.apache.org>
cc

Subject
Re: How can I access tomcat's logs using my jsp?






Lev A KARATUN wrote:
> Andre,
> 
> but if a symbolic link is deleted, its target remains unaffected. Are 
you 
> sure that undeployment can damage my logs somehow?
> 
I'd have to dig through the documentation (which you can also do).  But I 
am pretty sure 
that up to some version, Tomcat by default first deleted the *content* of 
whatever was 
pointed to by the symbolic link (in this case, the log directory), then 
the symbolic link 
itself.
As I recall, this behaviour was changed at some point, but maybe only when 
some parameter 
is specified.
The "Deployment" section of the Tomcat on-line documentation would be the 
place to start.

Anyway, the way (or a way) to go to do this properly has been indicated in 
a previous 
message by Chuck (the one where he rectified my own sloppy scenario).

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





-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
Lev A KARATUN wrote:
> Andre,
> 
> but if a symbolic link is deleted, its target remains unaffected. Are you 
> sure that undeployment can damage my logs somehow?
> 
I'd have to dig through the documentation (which you can also do).  But I am pretty sure 
that up to some version, Tomcat by default first deleted the *content* of whatever was 
pointed to by the symbolic link (in this case, the log directory), then the symbolic link 
itself.
As I recall, this behaviour was changed at some point, but maybe only when some parameter 
is specified.
The "Deployment" section of the Tomcat on-line documentation would be the place to start.

Anyway, the way (or a way) to go to do this properly has been indicated in a previous 
message by Chuck (the one where he rectified my own sloppy scenario).

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


Re: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
Andre,

but if a symbolic link is deleted, its target remains unaffected. Are you 
sure that undeployment can damage my logs somehow?

Best Regards, 
Karatun Lev,
RBRU IT Application Support ,
(495) 5464



André Warnier <aw...@ice-sa.com> 
03.02.2012 20:00
Please respond to
"Tomcat Users List" <us...@tomcat.apache.org>


To
Tomcat Users List <us...@tomcat.apache.org>
cc

Subject
Re: How can I access tomcat's logs using my jsp?






John Renne wrote:
> I've done this before but always used the apache in front of tomcat to 
serve the logfiles. 
> 
> If you're sure you want to let tomcat do the fileserving, I'ld suggest 
making a symlink in one of the application folders to the logsdirectory. 
That should do the trick. 
> 

I would not do that without being very very careful.  Undeploying the 
application may just 
delete all your logs.



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





-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by André Warnier <aw...@ice-sa.com>.
John Renne wrote:
> I've done this before but always used the apache in front of tomcat to serve the logfiles. 
> 
> If you're sure you want to let tomcat do the fileserving, I'ld suggest making a symlink in one of the application folders to the logsdirectory. That should do the trick. 
> 

I would not do that without being very very careful.  Undeploying the application may just 
delete all your logs.



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


Re: How can I access tomcat's logs using my jsp?

Posted by Lev A KARATUN <Le...@raiffeisen.ru>.
John,

unfortunately, I can't neither open symlinks via my browser (404) nor see 
them in the file list.


John Renne <jo...@gniffelnieuws.net> wrote on 03.02.2012 18:54:37:

> John Renne <jo...@gniffelnieuws.net> 
> 03.02.2012 18:55
> 
> Please respond to
> "Tomcat Users List" <us...@tomcat.apache.org>
> 
> To
> 
> "Tomcat Users List" <us...@tomcat.apache.org>
> 
> cc
> 
> Subject
> 
> Re: How can I access tomcat's logs using my jsp?
> 
> I've done this before but always used the apache in front of tomcat 
> to serve the logfiles. 
> 
> If you're sure you want to let tomcat do the fileserving, I'ld 
> suggest making a symlink in one of the application folders to the 
> logsdirectory. That should do the trick. 
> 
> John
> 
> On Feb 3, 2012, at 2:53 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
> > 
> > 
> > -----------------------------------
> > This message and any attachment are confidential and may be 
> privileged or otherwise protected from disclosure. If you are not 
> the intended recipient any use, distribution, copying or disclosure 
> is strictly prohibited. If you have received this message in error, 
> please notify the sender immediately either by telephone or by e-
> mail and delete this message and any attachment from your system. 
> Correspondence via e-mail is for information purposes only. ZAO 
> Raiffeisenbank neither makes nor accepts legally binding statements 
> by e-mail unless otherwise agreed. 
> > -----------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



-----------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
-----------------------------------

Re: How can I access tomcat's logs using my jsp?

Posted by John Renne <jo...@gniffelnieuws.net>.
I've done this before but always used the apache in front of tomcat to serve the logfiles. 

If you're sure you want to let tomcat do the fileserving, I'ld suggest making a symlink in one of the application folders to the logsdirectory. That should do the trick. 

John

On Feb 3, 2012, at 2:53 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
> 
> 
> -----------------------------------
> This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
> -----------------------------------


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