What if multiple log files need to be output in the same category? In fact, the truth is the same, first in Test. defined in java: private static Log logger1 = LogFactory. getLog ("myTest1"); private static Log logger2 = LogFactory. getLog ("myTest2"); then in log4j. add: log4j to properties. logger. myTest1 = DEBUG, test1log4j. appender. test1 = org. apache. log4j. fileAppenderlog4j. appender. test1.File =$ {myweb. root}/WEB-INF/log/test1.loglog4j. appender. test1.layout = org. apache. log4j. patternLayoutlog4j. appender. test1.layout. conver SionPattern = % d % p [% c]-% m % n log4j. logger. myTest2 = DEBUG, test2log4j. appender. test2 = org. apache. log4j. fileAppenderlog4j. appender. test2.File =$ {myweb. root}/WEB-INF/log/test2.loglog4j. appender. test2.layout = org. apache. log4j. patternLayoutlog4j. appender. test2.layout. conversionPattern = % d % p [% c]-% m % n, that is, a custom name (for example, "myTest1") for logger "), then in log4j. properties. Do not forget to use different logger for different logs (for example, logger1.info ("abc") for output to test1.log ")). Another problem is that these custom logs are output to the logs configured by log4j. rootLogger at the same time by default. How can they only be output to the specified logs? Don't worry. Here is a switch: log4j. additi.pdf. myTest1 = false it is used to set whether to output to log4j at the same time. in the logs configured by rootLogger, if it is set to false, it will not be output to other places! Note that "myTest1" here is the custom name you gave logger in the program! If you say that I just don't want to output this log to the logfile configured by log4j. rootLogger at the same time, I still want to output this log in stdout! Let's do it. Change your log4j. logger. myTest1 = DEBUG and test1 to the next step! Log4j. logger. myTest1 = DEBUG, test1, stdout