[Java] package log4j; import org. apache. log4j. logManager; import org. apache. log4j. logger; import org. apache. log4j. propertyConfigurator; public class Log4jG {// private static Logger log = Logger. getLogger (Log4jG. class); private static Logger log = LogManager. getLogger (Log4jG. class. getName (); private static Logger log1 = LogManager. getLogger ("myTest1"); private static Logger log2 = LogManager. getLogger ("myTest2"); private static Logger log3 = LogManager. getLogger ("myTest3"); public static void main (String [] args) {// basicaggregator. configure (); PropertyConfigurator. configure ("c: \ log4j. properties "); log. debug ("debug message"); log.info ("info message"); log. error ("error message"); log1.debug ("test1 debug"); log1.info ("test1 info message"); log1.error ("test1 error message "); log2.debug ("test2 debug"); log2.info ("test2 info message"); log2.error ("test2 error message"); log3.debug ("test3 debug "); log3.info ("test3 info message"); log3.error ("test3 error message") ;}} log4j. properties [java] log4j. rootLogger = INFO, A log4j. appender. A = org. apache. log4j. fileAppender log4j. appender. a. file = c:/rootlog.txt log4j. appender. a. layout = org. apache. log4j. patternLayout log4j. logger. myTest1 = DEBUG, test1 log4j. appender. test1 = org. apache. log4j. fileAppender log4j. appender. test1.File = c:/test1.log log4j. appender. test1.layout = org. apache. log4j. patternLayout log4j. appender. test1.layout. conversionPattern = % d % p [% c]-% m % n log4j. logger. myTest2 = DEBUG, test2 log4j. appender. test2 = org. apache. log4j. fileAppender log4j. appender. test2.File = c:/test2.log log4j. appender. test2.layout = org. apache. log4j. patternLayout log4j. appender. test2.layout. conversionPattern = % d % p [% c]-% m % n log4j. logger. myTest3 = DEBUG, R log4j. appender. R = org. apache. log4j. rollingFileAppender log4j. appender. r. file = C:/rolling. log # Control the maximum log file size log4j. appender. r. maxFileSize = 2KB # Archive log files (one backup file here) log4j. appender. r. maxBackupIndex = 1 log4j. appender. r. layout = org. apache. log4j. patternLayout log4j. appender. r. layout. conversionPattern = % p % t % c-% m % n