日期:2014-05-18  浏览次数:20711 次

研究过日志分类的大侠请进!
如何把日志按照自己指定的方式分类输出到不同的log文件呢?比如说根据不同平台的报文输出到对应平台的日志文件中去!
大虾帮帮偶!!

------解决方案--------------------
<?xml version= "1.0 " encoding= "UTF-8 " ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd ">
<log4j:configuration xmlns:log4j= "http://jakarta.apache.org/log4j/ ">
<appender name= "book.log " class= "org.apache.log4j.RollingFileAppender ">
<param name= "File " value= "./log/book.log " />
<param name= "Append " value= "true " />
<param name= "MaxFileSize " value= "5120KB "/>
<param name= "MaxBackupIndex " value= "10 "/>
<layout class= "org.apache.log4j.PatternLayout ">
<param name= "ConversionPattern " value= "%d{yyyy-MM-dd HH:mm:ss.SSS} %c %m "/>
</layout>
</appender>
<category name= "BOOK " >
<priority value = "debug " />
<appender-ref ref= "book.log " />
</category>
</log4j:configuration>

写log的时候,调用BOOK这个分类就会写到book.log中,依次类推。