If you do not have much background knowledge, you can search by yourself. It is generally incorrect to use log4j for segmentation on the Internet. The method is as follows:
Install log4j and configure log4j. properties to separate Catalina. Out. The configuration file is as follows:
01. log4j. rootlogger = info, Catalina
02.log4j.logger.com. danga. memcached. memcachedclient = warn, Catalina
03. # log4j. appender. Console = org. Apache. log4j. leleappender
04. # log4j. appender. Console. layout = org. Apache. log4j. patternlayout
05. # log4j. appender. Console. Encoding = UTF-8
06. # log4j. appender. console. layout. conversionpattern = [% P-% d {yyyy/mm/DD/hh/: mm/: SS}] % c {1 }. (% L)-% m % N
07.
08.
09. # define Catalina appenders
10. log4j. appender. Catalina = org. Apache. log4j. dailyrollingfileappender
11. log4j. appender. Catalina. File =$ {Catalina. Base}/logs/Catalina. Out
12. log4j. appender. Catalina. datepattern = '. 'yyyy-mm-dd
13. log4j. appender. Catalina. layout = org. Apache. log4j. patternlayout
14. log4j. appender. catalina. layout. conversionpattern = [% P-% d {yyyy/mm/DD/hh/: mm/: SS}] % c {1 }. (% L)-% m % N
15. log4j. appender. Catalina. append = true
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/fishrui/archive/2011/03/07/6228508.aspx
This is actually not feasible. It actually forces the Catalina. the out file is overwritten (that is, the file with the same name changed), and Catalina. (from this point of view, the filehandler of rootlogger is set to Catalina. the actual result is that the logger object of filehandler will print the information to this place.) in this way, Catalina. the out file is small. However, the information to be printed in the Catalina. Out file is lost.
Our goal is to make Catalina. the size of the out file is good, but the premise is that the message is not lost, or at least the message can be kept completely for a period of time (because the method I recommend also loses the message at the end, but the loss is a period of time ago ). To analyze Catalina. the reason why the out file is so large depends on its attributes. First, it has the creation and maintenance of the Tomcat startup process, which is very important because it was not created by the log tool, therefore, configuration cannot solve the problem of size control, and it will grow infinitely over time. Secondly, Catalina. the data in the out mainly has three sources (http://blog.163.com/marine_chen/blog/static/257570542007010103434661/): The data output to the standard input and the standard error output, the log information output through the commons logging interface, there is also an output that includes various Tomcat event statuses and other systems (such as Jakarta Struts. According to my understanding, according to the official statement, that is, all data with standard output and standard errors. In this way, the log information output through the commons logging interface is not printed to Catalina in the correct output file. out, which can reduce Catalina. but cannot control its final size. Therefore, the Catalina. Out method can only be used to control the Catalina. Out file (instead of overwriting the file with the same name. The correct method should be to use tools such as cronolog or write a shell script to regularly or quantitatively back up Catalina. Out and create Catalina. Out.