tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "改变自己" <1287567...@qq.com>
Subject 回复: 回复: tomcat 5 logs
Date Thu, 20 Mar 2014 14:24:32 GMT
thank you very much for your detailed explanation , 
now  i just  resolved it with another way,
i used a cronlog.exe which is a executable file and can be used for produce daily files;
and other configration  is the same as my primary way.


thank you all the same!
best regards 




------------------ 原始邮件 ------------------
发件人: "Christopher Schultz";<chris@christopherschultz.net>;
发送时间: 2014年3月20日(星期四) 晚上10:11
收件人: "Tomcat Users List"<users@tomcat.apache.org>; 

主题: Re: 回复: tomcat 5 logs



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

改变自己,

On 3/20/14, 12:30 AM, 改变自己 wrote:
> the source of my problem is that in the application ,we just used 
> many system.out sentence as a log output instead of using log4j, 
> because it is really a old applicaiton ; now we need to capture
> the the system.out information as a log;

You should take a look at the "swallowOutput" setting for your
<Context> element. You can find documentation about it here:
https://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Setting swallowOutput="true" will cause System.out and System.err
within the application to be routed to the context-logger, which you
should be able to redirect to a rotatable log file.

To configure the context logger, edit Tomcat's conf/logging.properties
file. There should already be some configuration like this:

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level
= INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers
= 3manager.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level
= INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers
= 4host-manager.org.apache.juli.FileHandler

These lines configure loggers for specific applications: the first
pair of lines set up the logger for the "manager" application while
the second pair configure those for the "host-manager" application.

To set up one for your own application, do the following:

Create a new "handler" (what actually writes to a file):

10my-context-path.org.apache.juli.FileHandler.level = FINE
10my-context-path.org.apache.juli.FileHandler.directory =
${catalina.base}/logs
10my-context-path.org.apache.juli.FileHandler.prefix = my-context-path.

Configure the context to write to the handler:

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/my-context-path].handler=10my-context-path-handler.org.apache.juli.FileHandler

Set the logging level:

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/my-context-path].level=INFO
(or ERROR, WARN, FINE, FINEST, ALL)


The above, along with swallowOutput="true" will take
System.out.println("Some log message") from your web application
deployed to "/my-context-path" and put it into
CATALINA_BASE/logs/my-context-path.[yyyy-MM-dd].log. The file should
be automatically rotated daily.

In case it's not obvious, the "my-context-path" text above should be
replaced with whatever your webapp's context path actually is. You can
call the log filename anything you want, and you can name the logger
(almost) anything you want -- check the documentation[1] -- but the
line with the [Catalina].[localhost].[/my-context-path] must match
your Service/Host/Context names (note the leading '/' in the context
path in the final portion of the logger name).

Finally, you should really upgrade. Tomcat 5 has been retired quite
some time ago, and Tomcat 6 will be considered for the chopping block
once Tomcat 8 is released. Fortunately, all of the above logging
configuration is available in Tomcat 5.5, 6.0, 7.0, and 8.0 so it
should still work for you if you upgrade.

Good luck,
- -chris

[1]
https://tomcat.apache.org/tomcat-5.5-doc/logging.html#java.util.logging
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTKvb9AAoJEBzwKT+lPKRYTKwQALKn+WqCHpEZpR6u4xt78cL3
wGceVd5nofSO0AK5A+FWFp80BhMWtucObmk11F4ZkasaLokFxQxmscA6UZt6pT7+
GCgM65R9uNvUqf15c/rL6KytKpI2mXvQRc4I+/HCIwZnELIu0+2j1BVoZsrB0Ms6
rBetukD/pHdWub5lPQGmOlgwt0tlb6Yam93+h9KpAd1CZLmpAHIY6pVZeDcX1ZNC
j3MqMUspQxo0+SIH+RQ0MFwbWwsZ0aPM4rulGGXDJtlVQZNpcDeL94YbucC5Remt
yDnmWQOuAZ/tyXsbbAfZWLRMtAEftMEsdFnYXDqXSKv71Un6NpoLOUvsSMqHYuyh
+IgiOqkpNiZUjQdJPztXZNFxOZWtlGJd3A60NGWU+5X2ZnDRfJ4dbCTBHsEFG4Fy
I/YIYhQQFuEj3ANsfpTjBSRhPtpeVlR65CUcReSEaM9hkDs4DKS2HLt15gzUSUIa
vRFoALkihS7esqrjhd+/Rexy/loz8kGX2tqGchj8DgENO2XL6FG/9QCu6p/Wv6kc
XXVsRKBkImE45YrVqjFnQNmjDhvckXr6nL/9lKE0gOkWWPneiDu3KXK0Vb3qFtf0
ASW7nC/umCOgdm5ERyGQhYm4Jry5Lco76BaUfSvtz9lFpMaiyk3yjunNVvcG/qVe
YiQQU321q/pgARYMHoMH
=5dC/
-----END PGP SIGNATURE-----

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

.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message