<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287690#M54962</link>
    <description>&lt;P&gt;That's what I thought the op was asking.&lt;/P&gt;

&lt;P&gt;"What I really want is to be able to add a listener in the config file attached to the binary". &lt;/P&gt;

&lt;P&gt;To me that meant, how do I put listener code in my config file.  Obviously I'm still a newb at .net as it was obvious to you.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Apr 2016 22:03:30 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-04-13T22:03:30Z</dc:date>
    <item>
      <title>Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287683#M54955</link>
      <description>&lt;P&gt;I am going off the question here:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/312914/httpeventcollectortracelistener-doesnt-flush.html"&gt;https://answers.splunk.com/answers/312914/httpeventcollectortracelistener-doesnt-flush.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The user is adding his listener programmatically in code, e.g:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  var listener = new HttpEventCollectorTraceListener(
                 new Uri(ConfigurationManager.AppSettings["SplunkUrl"], UriKind.Absolute), 
                 ConfigurationManager.AppSettings["AppToken"]);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I really want is to be able to add a listener in the config file attached to the binary -- could you light the way? Or is it not possible?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 00:06:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287683#M54955</guid>
      <dc:creator>mdufrasne</dc:creator>
      <dc:date>2016-04-12T00:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287684#M54956</link>
      <description>&lt;P&gt;@mdufrasne it is technically possible to do this, but you will need a derived listener and the code is going to get a bit ugly. The reason is because our listener requires parameters to be passed via the constructor because we did not optimize toward the config file based approach. Please file a bug though in our repo, as we could look into making this work, though it will be some time before we got to it. You could also consider sending us a PR.&lt;/P&gt;

&lt;P&gt;Here's how to do it yourself with the current listener. Basically you need to derive from our listener and add a default constructor. In your new listener add properties for all the parameters that would be passed via the constructor. The tricky part is the parameters in the ctor are then used to configure the internal &lt;A href="https://github.com/splunk/splunk-library-dotnetlogging/blob/master/src/Splunk.Logging.TraceListener/HttpEventCollectorTraceListener.cs#L127"&gt;HttpEventCollectorSender&lt;/A&gt; instance. You'll need to override this member using reflection APIs.&lt;/P&gt;

&lt;P&gt;The next question is when to do that override as you cannot do it in the default constructor as the properties are not initialized yet.&lt;/P&gt;

&lt;P&gt;One way to do it (cleaner but harder) is to override each of the methods in this &lt;A href="https://github.com/splunk/splunk-library-dotnetlogging/blob/master/src/Splunk.Logging.TraceListener/HttpEventCollectorTraceListener.cs#L171"&gt;region&lt;/A&gt; and have them check a flag which if not initialized, then overrides the sender. The check function needs a lock because multiple threads could be accessing the listener. Once the sender is overridden, then you can set the flag to true.&lt;/P&gt;

&lt;P&gt;The alternative is to have each property override the sender as it is set, or add a dummy boolean property that when set to true overrides the sender. Then you set the property last in your config. &lt;/P&gt;

&lt;P&gt;If it were me, I'd probably keep it simple and just go with the last option and use the dummy property. &lt;/P&gt;

&lt;P&gt;As far as how to wire up the listener itself in config, you have to specify the type and assembly as is mentioned in this &lt;A href="http://stackoverflow.com/questions/1176582/how-to-define-custom-tracelistener-in-app-config"&gt;SO&lt;/A&gt; post.&lt;/P&gt;

&lt;P&gt;Let me know if any of this makes sense &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 20:30:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287684#M54956</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T20:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287685#M54957</link>
      <description>&lt;P&gt;In terms of @jkat54's point it is more secure to not store your authentication information within a config file. When you do there is the concern that someone access the file or you accidentally share that file and put it in a Github repo somewhere etc which then exposes credentials. In this case HEC creds will only allow sending data so you will not be exposing Splunk login credentials, but it is still a potential vulnerability.&lt;/P&gt;

&lt;P&gt;One way to mitigate this is to encypt the Token using the &lt;A href="http://weblogs.asp.net/jongalloway/encrypting-passwords-in-a-net-app-config-file"&gt;DPAPI&lt;/A&gt; and then decrypt when you read it.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 20:40:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287685#M54957</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T20:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287686#M54958</link>
      <description>&lt;P&gt;Are you serious?  You can put code in a .config file?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 21:11:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287686#M54958</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-13T21:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287687#M54959</link>
      <description>&lt;P&gt;I never said anything about putting code in a conf file. We are talking about how to wire up an assembly in a config file. &lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 21:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287687#M54959</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T21:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287688#M54960</link>
      <description>&lt;P&gt;Not sure how you got that from the question &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; everytime I open my mouth here though... Every time!!!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 21:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287688#M54960</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-13T21:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287689#M54961</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;You said "Are you serious? You can put code in a .config file?"&lt;/P&gt;

&lt;P&gt;What did you mean by this / why did you ask this question?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 21:55:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287689#M54961</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T21:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287690#M54962</link>
      <description>&lt;P&gt;That's what I thought the op was asking.&lt;/P&gt;

&lt;P&gt;"What I really want is to be able to add a listener in the config file attached to the binary". &lt;/P&gt;

&lt;P&gt;To me that meant, how do I put listener code in my config file.  Obviously I'm still a newb at .net as it was obvious to you.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 22:03:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287690#M54962</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-13T22:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287691#M54963</link>
      <description>&lt;P&gt;Oh and my question was legitimate not a tongue in cheek or anything.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 22:06:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287691#M54963</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-13T22:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287692#M54964</link>
      <description>&lt;P&gt;Ahh I see. Well I agree with you that putting the code for the listener in the config file is a bad idea even if you could.&lt;/P&gt;

&lt;P&gt;Using config files to load custom listeners (that are defined outside in assemblies) is not uncommon though.&lt;/P&gt;

&lt;P&gt;Your point on credentials is definitely important so thanks for pointing that out.&lt;/P&gt;

&lt;P&gt;Apologies on any confusion.....&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 22:06:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287692#M54964</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T22:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287693#M54965</link>
      <description>&lt;P&gt;Ha ha I deleted my answer because it was so far off.  I'm glad you showed up and gracefully let me down from my high chair though &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;No apology needed.  I'm happy to learn!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 22:13:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287693#M54965</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-13T22:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to add HttpEventCollectorTraceListener in .NET config file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287694#M54966</link>
      <description>&lt;P&gt;It's all good!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 23:14:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-add-HttpEventCollectorTraceListener-in-NET/m-p/287694#M54966</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-04-13T23:14:43Z</dc:date>
    </item>
  </channel>
</rss>

