log4j.xml
xml version ="1.0" encoding ="UTF-8" ?>

< log4j:configuration xmlns:log4j ="http://jakarta.apache.org/log4j/" >
   < appender name ="com.enorth.lichen.common" class ="org.apache.log4j.RollingFileAppender" >  
     < param name ="File" value ="D:/common.log" />
     < param name ="Append" value ="true" />
     < param name ="MaxBackupIndex" value ="10" />
     < layout class ="org.apache.log4j.PatternLayout" >
       < param name ="ConversionPattern" value ="%d %p (%c:%L)- %m%n" />
     layout >
   appender >
   < appender name ="com.enorth.lichen.special" class ="org.apache.log4j.RollingFileAppender" >
     < param name ="File" value ="D:/special.log" />
     < param name ="Append" value ="true" />
     < param name ="MaxFileSize" value ="102400" />
     < param name ="MaxBackupIndex" value ="10" />
     < layout class ="org.apache.log4j.PatternLayout" >
       < param name ="ConversionPattern" value ="%d %p (%c:%L)- %m%n" />
     layout >
   appender >
   < logger name ="special.log" >
     < level value ="info" />
     < appender-ref ref ="com.enorth.lichen.special" />
   logger >
   < root >
     < appender-ref ref ="com.enorth.lichen.common" />
   root >
log4j:configuration >

程序调用
package com.enorth.lichen.util;

import org.apache.log4j.Logger;

/**
* @author 李晨    
* @version 创建时间:Sep 16, 2009 1:55:46 PM
*/

public class TestLog4jXml {

   public static void main(String[] args) {
//        DOMConfigurator.configure("log4j.xml");//加载.xml文件
//        PropertyConfigurator.configure("E:/study/log4j/log4j.properties");//加载.properties文件
        Logger log=Logger.getLogger( "special.log");
        log.info( "测试测试");
  }
}

日志文件
2009-09-16 14:00:11,140 INFO (special.log:16)- 测试测试