Very simple log4j2 XML configuration file using Console and File appender

后端 未结 4 1689
情深已故
情深已故 2020-12-07 07:40

I\'d like a very simple XML configuration file with a console and a file appender using log4j2.

(The Apache Website is killing me with much Information.)

4条回答
  •  借酒劲吻你
    2020-12-07 08:08

    log4j2 has a very flexible configuration system (which IMHO is more a distraction than a help), you can even use JSON. See https://logging.apache.org/log4j/2.x/manual/configuration.html for a reference.

    Personally, I just recently started using log4j2, but I'm tending toward the "strict XML" configuration (that is, using attributes instead of element names), which can be schema-validated.

    Here is my simple example using autoconfiguration and strict mode, using a "Property" for setting the filename:

    
    
        
            log/CelsiusConverter.log
        
        
            
                
            
            
                
            
            
                
            
        
        
            
                
                
                
                
            
        
    
    

提交回复
热议问题