Initializing Log4J with Spring?

前端 未结 5 1950
说谎
说谎 2020-11-28 06:30

I have a web app that uses Spring\'s Log4jConfigurer class to initialize my Log4J log factory. Basically it initializes Log4J with a config file that is off th

5条回答
  •  执念已碎
    2020-11-28 07:30

    Our standalone application required an SMTPAppender where the email config already exists in a spring config file and we didn't want that to be duplicated in the log4j.properties.

    I put the following together to add an extra appender using spring.

    
        
            
        
        
            addAppender
        
        
            
                
                    
                    
                    
                    
                    
                    
                        
                            
                                %d, [%5p] [%t] [%c] - %m%n
                            
                        
                    
                    
                        
                    
                
            
        
    
    

    We also have a log4j.properties file on the classpath which details our regular FileAppenders.

    I realise this may be overkill for what you require :)

提交回复
热议问题