How do I eliminate duplicate logging in log4net?

前端 未结 2 1557
长情又很酷
长情又很酷 2020-12-12 22:50

I have a program that makes many log4net calls to the \"myprogram\" loggers. It also calls other code that makes log4net calls to other loggers. I want to capture all logs h

2条回答
  •  佛祖请我去吃肉
    2020-12-12 23:10

    You are getting duplicated because you are telling it to log messages twice. I wouldn't recommend using additivity here since you might experience some side effects, simply remove unnecessary configuration:

    
        
        
        
    
    
        
    
    

    You don't need to indicate the appender-ref in the logger myprogram since it will inherit them from the root logger; if you specify them again it will log twice.

提交回复
热议问题