How do I make log4j create log files on demand only?

前端 未结 4 1426
天命终不由人
天命终不由人 2020-12-16 02:12

We have a modular application where modules have their own log4j logs (i.e. communication log and error log). The appenders and categories for these are all configured in th

4条回答
  •  旧巷少年郎
    2020-12-16 02:48

    In Log4j 2, both FileAppender and RollingFileAppender has the parameter "createOnDemand" which can be used to configure to create the log file only when a log event passed to the appender.

    Example:

    
        
            
        
        
    
    

    More details here: https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingRandomAccessFileAppender

提交回复
热议问题