how to setup the BlazeDS implementation with Log4j

 
1) add slf4j-api-1.5.8.jar,log4j-1.2.15.jar,slf4j-log4j12-1.4.2.jar into your project
 
please make yourself understand the relationship among them.
 
2) produce the following:
 
import org . slf4j . Logger ;  
import org . slf4j . LoggerFactory ;  
 
import flex . messaging . log . AbstractTarget ;  
import flex . messaging . log . LogEvent ;  
 
public class B lazeDSLog4j   extends AbstractTarget {  
   
// log4j levels:   OFF - FATAL - ERROR - WARN - INFO - DEBUG - TRACE - ALL  
   
// blazeds levels:  NONE - FATAL - ERROR - WARN - INFO - DEBUG - ALL  
 
   
@Override  
   
public void logEvent ( LogEvent event ) {  
       
Logger log = LoggerFactory . getLogger ( event . logger . getCategory ());  
 
       
if ( event . level >= LogEvent . ERROR )  
            log
. error ( event . message , event . throwable );  
       
else if ( event . level >= LogEvent . WARN )  
            log
. warn ( event . message , event . throwable );  
       
else if ( event . level >= LogEvent . INFO )  
             log
. info ( event . message , event . throwable );  
       
else if ( event . level >= LogEvent . DEBUG )  
             log
. debug ( event . message , event . throwable );  
       
else  
             log
. trace ( event . message , event . throwable );  
   
}  
}  
 
3) modify the configuration in servies-config.xml
 
<services-config> 
   
<logging> 
       
<target class="BlazeDSLog4j " level="All"> 
   
</logging> 
</services-config>
 
 

你可能感兴趣的:(log4j,职场,休闲,implementation,SBlazeDS)