Turning tracing off via app.config

后端 未结 6 1952
孤独总比滥情好
孤独总比滥情好 2020-12-08 05:20

I\'m trying to use System.Diagnostics to do some very basic logging. I figure I\'d use what\'s in the box rather than taking on an extra dependency like Log4Net or EntLib. <

6条回答
  •  感动是毒
    2020-12-08 05:39

    Late joining with a quick footnote about the app.config, in case this saves a couple of days from the life of someone out there:

    Assume you have the startup (.exe) projectA containing classA which makes use of projectB (.dll) containing classB.

    ClassB in turn makes use of a new TraceSource("classB") instance. In order to configure it you need to modify the app.config or projectA. Tweaking the app.config of projectB won't lead anywhere.

    Also note that the placement of the

    
    

    Section inside app.config seems to be causing problems if placed before the section:

    
    

    or after the section:

    
    

    At least in my case, I was getting errors when I attempted to place it in these locations in the app.config of my project. The layout that worked for me was:

    
    
        
             ...config sections here if any...
         
         
             
             
                 
                     
                        
                        
                     
                 
              
              
                 
              
         
         
             ...runtime sections here if any...
         
         
             ...usersettings sections here if any...
         
     
    

提交回复
热议问题