You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by 郑翼羽 <gr...@gmail.com> on 2010/07/06 09:35:48 UTC

How to split the default stdout log?

Hello everyone,

I am using Tomcat 5.5.28 in Windows systems. Because there are lots of codes
like "System.out.println(" some info here")" in the apps, after a few days
the file  "stdout_*.log" in the "/logs" folder becomes so large that we
cannot open it. Due to some reasons, I cannot modify the codes, so the only
solution is to make the log generated everyday.

I have tried the log4j, but I cannot redirect the stand output to the log
files. Only there log infos that send out by logging class can be recorded
in the logs generated by log4j.

Anyone know a simple solution to meet my needs?


-- 
郑翼羽

Re: How to split the default stdout log?

Posted by 郑翼羽 <gr...@gmail.com>.
My Environment:

Using CATALINA_BASE:   D:\tomcat5528

Using CATALINA_HOME:   D:\tomcat5528

Using CATALINA_TMPDIR: D:\tomcat5528\temp

Using JRE_HOME:        D:\java\jdk1.5.0_12

Using CLASSPATH:       D:\tomcat5528\bin\bootstrap.jar

Server version: Apache Tomcat/5.5.28

Server built:   Jul 24 2009 01:33:09

Server number:  5.5.28.0

OS Name:        Windows Vista

OS Version:     6.1

Architecture:   x86

JVM Version:    1.5.0_12-b04

JVM Vendor:     Sun Microsystems Inc.


I have used the tomcat unzipped from the zip file, and added it in the
system service using "service.bat install".


The default setting of the stdout in the Logging tabpage is : auto, at this
situation, when tomcat runs, it will generate log file in
"D:\tomcat5528\log" folder, and the related log file name will be
"stdout_20100707.log".


If I set that box to a fixed file, such as "tomcat.log", then if tomcat
restarts, it will generate a file called "tomcat.log". Before the next
restart (maybe many months),  all the output info are appended to that file,
which makes the log file to large.



On Tue, Jul 6, 2010 at 10:24 PM, André Warnier <aw...@ice-sa.com> wrote:

> 郑翼羽 wrote:
>
>> Thanks.
>>
>> The bad news is all the output codes are in a single webapp, and have no
>> hope to use log4j instead of the current "system.out" codes.
>>
>> Just I hope to find a way that can make tomcat generate a stdout.log file
>> eveyday, or at any interval.
>>
>>  Hi again.
> I tried what I suggested earlier (with the Apache rotatelogs utility), but
> that does not seem to work. (*)
>
> Can you confirm :
> 1) that you are running Tomcat 5.5 as a Windows Service
> 2) if yes, what you currently see when you run the tomcat5w.exe GUI, in the
> Logging tab, in the boxes for STDOUT and STDERR
> 3) what name do your logfiles have ?
>
> Thanks
>
>
> (*) When i do that, I get a logfile
> tomcat_dir/logs/jakarta_service_20100706.log containing 2 lines :
> [2010-07-06 16:12:50] [591  javajni.c] [error] Could not create instance of
> java/io/FileOutputStream
> [2010-07-06 16:12:50] [591  javajni.c] [error] Could not create instance of
> java/io/FileOutputStream
>
> from which i suspect that the tomcat5.exe/procrun wrapper does not like it,
> when one tries to give it something like this as a destination for its
> logfiles :
> |c:/tomcat5.5/bin/rotatelogs.exe -l C:/Tomcat5.5/logs/stdout.%Y.%m.%d 86400
>
> (I also tried flipping the slashes the other way, with no more success).
>
> This was with
> C:\Tomcat5.5\bin>version.bat
> Using CATALINA_BASE:   C:\Tomcat5.5
> Using CATALINA_HOME:   C:\Tomcat5.5
> Using CATALINA_TMPDIR: C:\Tomcat5.5\temp
> Using JRE_HOME:        C:\Java6jdk
> Using CLASSPATH:       C:\Tomcat5.5\bin\bootstrap.jar
> Server version: Apache Tomcat/5.5.26
> Server built:   Jan 28 2008 01:35:23
> Server number:  5.5.26.0
> OS Name:        Windows XP
> OS Version:     5.1
> Architecture:   x86
> JVM Version:    1.6.0_06-b02
> JVM Vendor:     Sun Microsystems Inc.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
郑翼羽

Re: How to split the default stdout log?

Posted by André Warnier <aw...@ice-sa.com>.
郑翼羽 wrote:
> Thanks.
> 
> The bad news is all the output codes are in a single webapp, and have no
> hope to use log4j instead of the current "system.out" codes.
> 
> Just I hope to find a way that can make tomcat generate a stdout.log file
> eveyday, or at any interval.
> 
Hi again.
I tried what I suggested earlier (with the Apache rotatelogs utility), but that does not 
seem to work. (*)

Can you confirm :
1) that you are running Tomcat 5.5 as a Windows Service
2) if yes, what you currently see when you run the tomcat5w.exe GUI, in the Logging tab, 
in the boxes for STDOUT and STDERR
3) what name do your logfiles have ?

Thanks


(*) When i do that, I get a logfile tomcat_dir/logs/jakarta_service_20100706.log 
containing 2 lines :
[2010-07-06 16:12:50] [591  javajni.c] [error] Could not create instance of 
java/io/FileOutputStream
[2010-07-06 16:12:50] [591  javajni.c] [error] Could not create instance of 
java/io/FileOutputStream

from which i suspect that the tomcat5.exe/procrun wrapper does not like it, when one tries 
to give it something like this as a destination for its logfiles :
|c:/tomcat5.5/bin/rotatelogs.exe -l C:/Tomcat5.5/logs/stdout.%Y.%m.%d 86400

(I also tried flipping the slashes the other way, with no more success).

This was with
C:\Tomcat5.5\bin>version.bat
Using CATALINA_BASE:   C:\Tomcat5.5
Using CATALINA_HOME:   C:\Tomcat5.5
Using CATALINA_TMPDIR: C:\Tomcat5.5\temp
Using JRE_HOME:        C:\Java6jdk
Using CLASSPATH:       C:\Tomcat5.5\bin\bootstrap.jar
Server version: Apache Tomcat/5.5.26
Server built:   Jan 28 2008 01:35:23
Server number:  5.5.26.0
OS Name:        Windows XP
OS Version:     5.1
Architecture:   x86
JVM Version:    1.6.0_06-b02
JVM Vendor:     Sun Microsystems Inc.


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


RE: How to split the default stdout log?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: 郑翼羽 [mailto:groundzyy@gmail.com]
> Subject: Re: How to split the default stdout log?
> 
> The bad news is all the output codes are in a single 
> webapp, and have no hope to use log4j instead of the 
> current "system.out" codes.

Read what I posted - use swallowOutput to capture the writes to System.out.

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


Re: How to split the default stdout log?

Posted by 郑翼羽 <gr...@gmail.com>.
Thanks.

The bad news is all the output codes are in a single webapp, and have no
hope to use log4j instead of the current "system.out" codes.

Just I hope to find a way that can make tomcat generate a stdout.log file
eveyday, or at any interval.



On Tue, Jul 6, 2010 at 8:51 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: 郑翼羽 [mailto:groundzyy@gmail.com]
> > Subject: Re: How to split the default stdout log?
> >
> > But when tomcat5 starts, it will generate a file like
> > stdout_yyyymmdd.log, but when it runs for a couple of
> > days, there will be only one file
>
> Not sure there's going to be any ready way for Tomcat to fix sloppy webapp
> programming, but start with setting swallowOutput to true in the <Context>
> of interest (or in the global one).  This will divert stdout and stderr for
> each webapp to the webapp's logger.  You can then use log4j in the webapp,
> and make use of its built-in rotation capabilities.
>
> Look here for the doc:
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
> http://tomcat.apache.org/tomcat-5.5-doc/logging.html
>
> You should also take a look at the FAQ entries on logging:
> http://wiki.apache.org/tomcat/FAQ/Logging
>
>  - 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.
>
>


-- 
郑翼羽

RE: How to split the default stdout log?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: 郑翼羽 [mailto:groundzyy@gmail.com]
> Subject: Re: How to split the default stdout log?
> 
> But when tomcat5 starts, it will generate a file like
> stdout_yyyymmdd.log, but when it runs for a couple of
> days, there will be only one file

Not sure there's going to be any ready way for Tomcat to fix sloppy webapp programming, but start with setting swallowOutput to true in the <Context> of interest (or in the global one).  This will divert stdout and stderr for each webapp to the webapp's logger.  You can then use log4j in the webapp, and make use of its built-in rotation capabilities.

Look here for the doc:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
http://tomcat.apache.org/tomcat-5.5-doc/logging.html

You should also take a look at the FAQ entries on logging:
http://wiki.apache.org/tomcat/FAQ/Logging

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


Re: How to split the default stdout log?

Posted by André Warnier <aw...@ice-sa.com>.
郑翼羽 wrote:
> Thanks Andre!
> 
> But when tomcat5 starts, it will generate a file like stdout_yyyymmdd.log,
> but when it runs for a couple of days, there will be only one file, and all
> the infos are appended to that file. What I want is that tomcat can
> automatic generate multiple files such as one file one day so that the
> single log file will not be so large.
> Like in log4j, I can set the parameter like
> "log4j.appender.R=org.apache.log4j.DailyRollingFileAppender" so that
> everyday it will generate a new file.
> 
> in the "logging" tab page, I can only redirect the stdout to a single file.
> 
> Does it support parameters like "D:\Tomcat 5.5\logs\{%date%}.log"?
> 

I don't know, and I did not find anything to that effect in the Tomcat or Daemon 
documentation.
But you could try the following :

In the Apache httpd distribution, there is a program called "rotatelogs.exe".
Its documentation is here : http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

You could try to download Apache, extract this program, add it to the tomcat/bin 
directory, and then in tomcat5w.exe try to set the filename to something like :

|D:/Tomcat 5.5/bin/rotatelogs.exe -l D:/Tomcat 5.5/logs/stdout.%Y.%m.%d 86400

I have never tried this, and I don't know if it works.
If it does, then let us know, because it might be handy for others.

Note : I know that this is not the default in the Tomcat installation, but I always 
recommend to install programs in directory paths *without embedded spaces* (e.g. 
"D:/tomcat5.5" instead of "D:/tomcat 5.5".  One of the reasons is shown above : does one 
need to quote this path or not, and if yes how ?


> 
> 
> On Tue, Jul 6, 2010 at 4:13 PM, André Warnier <aw...@ice-sa.com> wrote:
> 
>> 郑翼羽 wrote:
>>
>>> Hello everyone,
>>>
>>> I am using Tomcat 5.5.28 in Windows systems. Because there are lots of
>>> codes
>>> like "System.out.println(" some info here")" in the apps, after a few days
>>> the file  "stdout_*.log" in the "/logs" folder becomes so large that we
>>> cannot open it. Due to some reasons, I cannot modify the codes, so the
>>> only
>>> solution is to make the log generated everyday.
>>>
>>> I have tried the log4j, but I cannot redirect the stand output to the log
>>> files. Only there log infos that send out by logging class can be recorded
>>> in the logs generated by log4j.
>>>
>>> Anyone know a simple solution to meet my needs?
>>>
>>>  Hi.
>> You do not say, but I presume that you are running Tomcat 5.5 as a Windows
>> Service.
>> If so, then Tomcat (or rather the JVM which runs Tomcat), is running inside
>> of a "wrapper" program called "tomcat5.exe" (tomcat_dir/bin/tomcat5.exe).
>> This program "catches" the stdout/stderr of the JVM, and redirects them to
>> files.
>> To which files it redirects them, is stored in the Windows Registry.
>> When tomcat5.exe starts, it reads a series of parameters from the Registry,
>> and then starts the JVM (and Tomcat) using these parameters.
>>
>> There is another program in tomcat_dir/bin, called "tomcat5w.exe".
>> This is a GUI which enables you to change these Registry parameters used by
>> tomcat5.exe.
>> Double-click on the tomcat5w.exe program, and navigate to the "Logging"
>> tab.
>>
>> Maybe this gives you an idea.
>>
>> For a complete explanation, start here : http://commons.apache.org/daemon/
>> tomcat5.exe is really a renamed prunsrv
>> tomcat5w.exe is really a renamed prunmgr
>>
>>
>> ---------------------------------------------------------------------
>> 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 to split the default stdout log?

Posted by 郑翼羽 <gr...@gmail.com>.
Thanks Andre!

But when tomcat5 starts, it will generate a file like stdout_yyyymmdd.log,
but when it runs for a couple of days, there will be only one file, and all
the infos are appended to that file. What I want is that tomcat can
automatic generate multiple files such as one file one day so that the
single log file will not be so large.
Like in log4j, I can set the parameter like
"log4j.appender.R=org.apache.log4j.DailyRollingFileAppender" so that
everyday it will generate a new file.

in the "logging" tab page, I can only redirect the stdout to a single file.

Does it support parameters like "D:\Tomcat 5.5\logs\{%date%}.log"?



On Tue, Jul 6, 2010 at 4:13 PM, André Warnier <aw...@ice-sa.com> wrote:

> 郑翼羽 wrote:
>
>> Hello everyone,
>>
>> I am using Tomcat 5.5.28 in Windows systems. Because there are lots of
>> codes
>> like "System.out.println(" some info here")" in the apps, after a few days
>> the file  "stdout_*.log" in the "/logs" folder becomes so large that we
>> cannot open it. Due to some reasons, I cannot modify the codes, so the
>> only
>> solution is to make the log generated everyday.
>>
>> I have tried the log4j, but I cannot redirect the stand output to the log
>> files. Only there log infos that send out by logging class can be recorded
>> in the logs generated by log4j.
>>
>> Anyone know a simple solution to meet my needs?
>>
>>  Hi.
> You do not say, but I presume that you are running Tomcat 5.5 as a Windows
> Service.
> If so, then Tomcat (or rather the JVM which runs Tomcat), is running inside
> of a "wrapper" program called "tomcat5.exe" (tomcat_dir/bin/tomcat5.exe).
> This program "catches" the stdout/stderr of the JVM, and redirects them to
> files.
> To which files it redirects them, is stored in the Windows Registry.
> When tomcat5.exe starts, it reads a series of parameters from the Registry,
> and then starts the JVM (and Tomcat) using these parameters.
>
> There is another program in tomcat_dir/bin, called "tomcat5w.exe".
> This is a GUI which enables you to change these Registry parameters used by
> tomcat5.exe.
> Double-click on the tomcat5w.exe program, and navigate to the "Logging"
> tab.
>
> Maybe this gives you an idea.
>
> For a complete explanation, start here : http://commons.apache.org/daemon/
> tomcat5.exe is really a renamed prunsrv
> tomcat5w.exe is really a renamed prunmgr
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
郑翼羽

Re: How to split the default stdout log?

Posted by André Warnier <aw...@ice-sa.com>.
郑翼羽 wrote:
> Hello everyone,
> 
> I am using Tomcat 5.5.28 in Windows systems. Because there are lots of codes
> like "System.out.println(" some info here")" in the apps, after a few days
> the file  "stdout_*.log" in the "/logs" folder becomes so large that we
> cannot open it. Due to some reasons, I cannot modify the codes, so the only
> solution is to make the log generated everyday.
> 
> I have tried the log4j, but I cannot redirect the stand output to the log
> files. Only there log infos that send out by logging class can be recorded
> in the logs generated by log4j.
> 
> Anyone know a simple solution to meet my needs?
> 
Hi.
You do not say, but I presume that you are running Tomcat 5.5 as a Windows Service.
If so, then Tomcat (or rather the JVM which runs Tomcat), is running inside of a "wrapper" 
program called "tomcat5.exe" (tomcat_dir/bin/tomcat5.exe).
This program "catches" the stdout/stderr of the JVM, and redirects them to files.
To which files it redirects them, is stored in the Windows Registry.
When tomcat5.exe starts, it reads a series of parameters from the Registry, and then 
starts the JVM (and Tomcat) using these parameters.

There is another program in tomcat_dir/bin, called "tomcat5w.exe".
This is a GUI which enables you to change these Registry parameters used by tomcat5.exe.
Double-click on the tomcat5w.exe program, and navigate to the "Logging" tab.

Maybe this gives you an idea.

For a complete explanation, start here : http://commons.apache.org/daemon/
tomcat5.exe is really a renamed prunsrv
tomcat5w.exe is really a renamed prunmgr


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