I'm using Graphite.NET for logging to statsD. Underneath the hood, it uses UdpClient to write to the statD server. Source. I think makes sense to create this as a singleton because I will be logging frequently and it seems that there will be a lot of overhead in creating this client and connecting every time I want to log. Is there any downside to doing this? What happens if the connection gets interrupted: will an exception be thrown? Will my logger be recreated by StuctureMap next time I try to use the logger? Here's what my SM configuration looks like:
x.For<IStatsDClientAdapter>()
.Singleton()
.Use<StatsDClientAdapter>()
.Ctor<string>("hostname").EqualToAppSetting("GraphiteHostname")
.Ctor<int>("port").EqualToAppSetting("GraphitePort")
.Ctor<string>("keyPrefix").EqualToAppSetting("GraphiteKeyPrefix");