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