posted on Monday, August 01, 2005 3:56 PM
by
Benjy
Log 'em all
If Metallica were coders that would have been the title of their first album, instead of Kill 'em all.
I finally won one battle with Enterprise Library. I uninstalled the Jan version, the hands on labs, the June version, everything and installed just June 05 and the Hands On Labs. Lo and behold, the logging exercise started working. Why? I havent the foggiest. It could be because of some clashes with the Jan version, but then again, i dont know why that would arise. One thing that strikes me as a possible factor is a line in the app.config which has an "IgnoreSectionHandler" presumably telling the framework not to look for the loggingConfiguration element inside the config file but to go for a separate file.
The second battle, BizTalk and Ent Lib is sort of won. I say 'Sort of' because it appeared to work a couple of hours ago when it shouldnt !! Let me explain.
I took Andy Morrisons sample for Ent Lib logging. Andy uses a technique of marking his assembly as belonging to a separate AppDomain and setting the config file for that AppDomain which functions just like a regular app.config file and from there it points to the loggingConfiguration and loggingDistributorConfiguration files (usually in the same folder)
(a) I tried it out, straight from the can, but my old bugbear appeared, saying "the section loggingConfiguration could not be found in the BTSNTSVC.exe.config or the machine.config"
(b) Next, I got rid of the old Ent Lib projects from his solution to avoid any PublicKey or version clashes. I set a reference to my Ent Lib DLLs' which had just been strong named. No luck. Same message
(c) Then I added the "IgnoreSectionHandler" line into the configSections element of BTSNTSVC . Again, no luck.
(d) Finally, in desperation i copied the entire contents of the dll.config (the config sections, the pointers to loggingConfiguration etc) ans pasted it into BTSNTSVC.exe.config, re-started the host and... whaddya know... it logged something to the event log.
I left it at that stage, rejoicing that it finally worked. After a while though, sanity prevailed. HOW CAN IT POSSIBLY WORK? The thing is, even if it read the stuff i pasted in, there is no loggingConfiguration file in the BizTalk program files folder so it cant have found the instructions from there.
That leaves me with only two options
(a) there must be some default logging setup in EntLib to direct stuff into the event log (or)
(b) the host re-start was the one which did the trick. It read through my stuff, went past it, read the AppDomain thingy and worked as Andy had intended it to.
Very strange indeed. I need to test that out again tomorrow. One thing which didnt happen is that a log text file which should have been a replica of the event log messages, didnt appear as the documentation was expecting it to. I'll see if i can adjust the loggingConfiguration and add that sink in. That might do the trick.
I'll keep y'all posted. If that works, then i can move on to the Data block. Soon I will become a 'block'head :-)