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

Alec,

On 11/27/13, 11:45 AM, Tomcat Random wrote:
> I'm running Tomcat 7.0.42 on RHEL. Currently all my exceptions are 
> handled with e.printStackTrace() and go to catalina.out, which 
> doesn't rotate.

Yuk.

> Could someone be so kind as to recommend a better way to handle 
> logging, with specific steps.

Yes and no. How to handle logging? Use a logging framework. log4j,
java.logging are popular and there are others. I find java.logging to be
... frankly frustrating to configure. I would recommend log4j.

As for API, both Apache commons-logging and slf4j are popular. Note that
you need a "real" logging framework underneath to actually do the
logging. I'm not sure if it's worthwhile adding that extra layer rather
than simply coding directly to the logging framework's API. I have used
log4j directly for years and I'm quite happy.

The biggest problem is that you are going to have to modify a lot of
your code. Every modification is trivial and easy, but if you are
logging properly, then you probably have a big job ahead of you. Since
you aren't using a logging framework, you probably don't have trace,
debug, etc. logging so that makes things a bit easier... you just have
to grep for "printStackTrace" and replace that with something like
"logger.error("Bad stuff", exception);".

> Daily error logs would be a good start, instead of one giant 
> catalina.out file.

Any logging framework will be able to roll your files for you. Just read
the docs for how to configure them to behave that way.

There is a stop-gap measure if you are running on a reliable system:
you can modify catalina.sh (or however you launch Tomcat) to pipe
stdout to a program like chronolog instead of redirecting to a file.
Chronolog was made to take stdin and write to a rolling file. I'm sure
a setup like that is a big fragile, so keep your eyes on it. But it
can get you out of a bind while you re-work your application to log
properly.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSlilNAAoJEBzwKT+lPKRYi54P/2FpcDnAWieUq25COU+V294K
wCNqBBc3cXMyHKF7x7PljUa5muZD/P6MjfnROzuQh9FPbhgpaSIGnShFdmDL5FGj
BFzTItda8gV2iGWaW5J6ttO4S6IlaTsTLnQ0twDpu08dt5gkAWNDQKjP3fgZLySd
GMhuwUm55wCiWNwVeRUbsvBvSj90lgM8ix0SA0s192/p6JUIEqkka9yNVmK5IDiE
siwIM/k4X+g95wfBvT/Kxvh4j9/G+Nl/M/OQ7OIfNpDvJrTMKOya32n8N+OIGh3X
51vre9VPL0k5SRRupmfKb4iLNpR+5JKvDYmUsGKwWsJztMaEDU0b4ff03iisOv0o
V0wH7++QnvRAa2rXQ2YVVtMR/sm/8PmG5olOr+nopcM8ZYF8j86WqjHW3lE1mddM
k++KW8q+YgTNGn5i7z3LEQ67P3jCB0enrflPa2uqH1A2XhEdmTQR2k72TB4brF5t
uyc5es8ZfMvKer69wlcAlgLYX8Z+HvPikE+KTV2zsaRPU+Aiy02jLp65peXn6NGh
TJyeihZbnjMrN7/mv1HlRcNzU1RY14Vi2+VXS0aHh35lfSE8qqcPSEakw3w/jRRO
VVNMus3VTuU/BehpauRtSsmha6bN7v0mZH1cH8NZLh3Qq0KfD67UreWGqDKpqCLQ
6rcewerS2IVIU947dJv+
=lcU5
-----END PGP SIGNATURE-----

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

Reply via email to