You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ja...@ifishbone.com on 2014/03/24 08:55:49 UTC
Could I ask something about tomcat's catalina categorize?
Dear Apache SoftwareFundation
Could I categorize catalina.out by virtual host ? Is any setting can do
that?
I have been finding the answer for two weeks but still got nothing.
Could give me a answer and reply . Thank you very much.
Re: Could I ask something about tomcat's catalina categorize?
Posted by Ja...@ifishbone.com.
Thank all , I figure it out , I was trying log4j to output catalina.out at
first ,and it did't work because swallowOptupt attribute didn't set .That
is important and it discribed in the offical documentation , according to
documentation
====================================================================================================================
When running Tomcat on unixes, the console output is usually redirected to
the file named catalina.out. The name is configurable using an environment
variable. (See the startup scripts). Whatever is written to
System.err/out will be caught into that file. That may include:
Uncaught exceptions printed by java.lang.ThreadGroup.uncaughtException(..)
Thread dumps, if you requested them via a system signal
When running as a service on Windows, the console output is also caught
and redirected, but the file names are different.
The default logging configuration in Apache Tomcat writes the same
messages to the console and to a log file. This is great when using Tomcat
for development, but usually is not needed in production.
Old applications that still use System.out or System.err can be tricked by
setting swallowOutput attribute on a Context. If the attribute is set
to true, the calls to System.out/err during request processing will be
intercepted, and their output will be fed to the logging subsystem using
thejavax.servlet.ServletContext.log(...) calls.
Note, that the swallowOutput feature is actually a trick, and it has its
limitations. It works only with direct calls to System.out/err, and only
during request processing cycle. It may not work in other threads that
might be created by the application. It cannot be used to intercept
logging frameworks that themselves write to the system streams, as those
start early and may obtain a direct reference to the streams before the
redirection takes place.
====================================================================================================================
and it is my log4j.properties setting below , it totally work now .
============================================================================================================
log4j.rootLogger=INFO, CATALINA, R
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.out
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.base}/logs/webapps2.out
log4j.appender.R.Append=true
log4j.appender.R.Encoding=UTF-8
log4j.appender.R.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
# Configure which loggers log to which appenders
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO,
CATALINA
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[jacky.com]=INFO,
R
==============================================================================================================
Re: Could I ask something about tomcat's catalina categorize?
Posted by Ja...@ifishbone.com.
For example , I have two virtual host settings in server.xml , one is
"jacky.net" ,the other is "jacky.com"
How do I output "jacky.net" and "jacky.com" to the different catalina file
, then I can categorize it easier when a exception throw out.
Now I am survering log4j and trying it but didn't work yet .
If someone has better opinion , please reply to me, thank you very much .
###############################################################
<Host name="jacky.net" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
<Host name="jacky.com" appBase="webapps2"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
################################################################
Re: Could I ask something about tomcat's catalina categorize?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
To whom it may concern,
On 3/24/14, 3:55 AM, Jacky_He@ifishbone.com wrote:
> Dear Apache SoftwareFundation
FYI this is a communicty of volunteers. None of us speaks for the ASF
itself.
> Could I categorize catalina.out by virtual host ? Is any setting
> can do that?
>
> I have been finding the answer for two weeks but still got
> nothing.
>
> Could give me a answer and reply . Thank you very much.
It's very unclear what you are asking. What does "categorize
catalina.out by virtual host" mean? Do you mean you want the messages
written to catalina.out to have the "source" virtual host attached to
them?
The short answer is "no". You probably should do things differently:
use "swallowOutput" on each Context and log each context's System.out
and System.err to a separate file.
Then go fix your web application to stop spewing logs to stdout.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBCAAGBQJTMHDvAAoJEBzwKT+lPKRYmvgQAJzty/GjXbnH8VUuxT79cLbN
fkYxvJnqGZZv8f5fLv6pM4yNmdUIe2QT5DDY5LUd9xrEGfwOgZP/DkHQyDWn5kgK
nv0b2eMeJAGTqV0xhInf9FRbV+4m2GVYDQJyB4A3pLeXqNhL/EyoBupV0sqr781W
4+TwWwYyuWy4jiArUabAJS8TGmlvbemQS3A+ZQ20y8K5drKwoD3ZzlQgI3et0Ico
8cQB20cVb6wH3VAyylGbs+r10P1nOFIRojKJ9bvq2q2yaET7eJ337t1RMqXu4QP4
WmfIQR89QrTUvC7j9Q/qCQBCKo8Bwi47zQtm/1dCBq8ylmEy53CvRc/1Zn8UkJ7R
njy5G9PHyhbkyHPVhG6SkDK3IVfqkP0p1FujeuAfpmZVtcWfUYmGm///+RS1rijL
nf+9clJNSr/wTPYoztY9ugwd9ui40h7ViF9FEvruquokUXRMYJQdtC+VjZ+v0SLO
is/Oy/VeLuzx2vzKyTGDsjFOrBDTFdtWjc0lAZG15ChNKdttqQQSagwfwLsFYZ/q
BKL3nyQ5Xl1TSuBs/uNiPwO9+dAJNuulmHUUOClWXB4aUR23z6DJ1kqDgwypWVwg
fTuZQqlpI9LhKhEflMyEcElJLQcJ6dvFBfS4gMdZrYLePCcIz3c3r32G7LtdyrR/
/k6fPv2UMymZPrfIBGUD
=1tQo
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org