Semantic Logging setup through config file

Topics: Semantic Logging Application Block
May 22, 2013 at 4:23 PM
Edited May 22, 2013 at 4:24 PM
Is there any documentation yet on how to get Semantic Logging, logging through setup in a config file? I want to do something similar to code I have in my global.asax.cs but need it in a config for my wcf service websites.
// Create and enable an observable event listener
var listener = new ObservableEventListener();
listener.EnableEvents(GeneralExceptionEventSource.Log, EventLevel.LogAlways, Keywords.All);

// Subscribe the event sink to the listener
listener.LogToRollingFlatFile(@"Temp\Log\events.log", 5000, "MM-dd-yyyy", RollFileExistsBehavior.Increment, RollInterval.Week, new XmlEventTextFormatter(), 4);
May 22, 2013 at 4:59 PM
From the Developer’s Guide to Microsoft Enterprise Library Preview:

"If you are using the block in-process, then you provide the configuration information for your sinks in code; if you are using the block out-of-process, then you provide the configuration information in an XML file. "

Randy Levy
Enterprise Library support engineer
Support How-to
May 23, 2013 at 10:47 AM
Additionally to Randy's answer, I would say that out-of-process service will be a good candidate for tracing/monitoring your websites not only for moving the coded configuration to a declarative approach but also for taking advantage of the decouple feature provided by this implementation so you don't need to restart your web application in case of changes in your logging settings and some other benefits as well.

May 23, 2013 at 12:46 PM
I understand how this is a more useful approach, but it introduces a lot more complexity and deployment issues. It's too bad there aren't stages to move between, easy and most useful. I really wish ent lib 6 was as easy to get up and running as the previous versions were even with their dependency on unity.
May 23, 2013 at 2:15 PM
Thanks for the feedback. However, I would also like to add that semantic logging is mostly the built-in typed events which has all the documented benefits.
Entlib v6 will add value in a seamless and almost " transparent" way as a complement to ETW. In that regards, you can opt-in at any time to add out-of-proc support in a very straightforward way simply by installing the service (already provided command lines for easy script deployment) along with the mentioned config settings.
My apologies if I'm missing something but it looks like the footprint is not grater than the previous app config settings and deployment effort.

Feb 6, 2015 at 4:32 PM
I was looking forward to switching to the semantic logging block because I was hoping for better performance due to the use of ETW, but without being able to make logging configuration changes via an XML or other config file this is not practical for us. We write software that is deployed to hundreds of clients that are running on different versions of windows OSs and our code is used in web apps and services. With the old MS P&P application block we can simply modify the XML file to increase the level of logging for a specific app at a specific client that we need to troubleshoot.
We can't possibly support the out-of-process version because that entails installing the out-of-process app on tens of thousands of computers with various configurations and we just don't have the time to support getting that working if even just 1% has problems.

It seems we should not use the Semantic Logging block if we need to be able to change logging levels without recompiling. Is that correct?