With respect to versioning, the documentation for the Semantic Logging Application Block recommends:
If you do need to modify your EventSource class, you should restrict your changes to adding methods to support new log messages, and adding overloads of existing methods (that would have a new event ID). You should not delete or change the signature of existing methods.
Suppose I had the following EventSource class:
[EventSource(Name = "Instrumentation")]
public class InstrumentationEventSource : EventSource {
private static readonly Lazy<InstrumentationEventSource> Singleton = new Lazy<InstrumentationEventSource>(() => new InstrumentationEventSource());
public static InstrumentationEventSource Log { get { return Singleton.Value; } }
private InstrumentationEventSource() {}
[Event(eventId: 901)]
public void EndPage(string url) {
WriteEvent(901, url);
}
}
And then I wanted to add support for logging a query string. Could I add an overloaded method with the same ID?
[Event(eventId: 901)]
public void EndPage(string url) {
WriteEvent(901, url);
}
[Event(eventId: 901)]
public void EndPage(string url, string queryString) {
WriteEvent(901, url, queryString);
}
How can I support future modifications with as little impact to applications or an out-of-process host logging application?
Could I keep the signatures simpler by making the additions in a model class?
public class LogData {
public string url { get; set; }
// public string queryString { get; set; }
}
and
[Event(eventId: 901)]
public void EndPage(LogData data) {
WriteEvent(901, data);
// Or does the params object[] args parameter not support classes?
// WriteEvent(901, data.url);
// And this would have to be changed anyway?
// WriteEvent(901, data.url, data.queryString);
}
I'm not really sure where Event ID fits into it all, and how much the maintenance of the EventSource
class needs to exert care over this.