<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx</link><description>How can a .NET app connect to a *nix Syslog? It's pretty easy, really.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: .NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx#252951</link><pubDate>Fri, 05 Nov 2004 19:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:252951</guid><dc:creator>Uwe Keim</dc:creator><description>What about writing an appender for LOG4NET (&lt;a target="_new" href="http://logging.apache.org"&gt;http://logging.apache.org&lt;/a&gt;)?&lt;br&gt;&lt;br&gt;LOG4NET is for me the by far best logging framework.</description></item><item><title>re: .NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx#252975</link><pubDate>Fri, 05 Nov 2004 20:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:252975</guid><dc:creator>Dino</dc:creator><description>Uwe queries:&lt;br&gt;&amp;gt; What about writing an appender for LOG4NET &lt;br&gt;&lt;br&gt;Why not?  Should be pretty simple, but I am not volunteering!   I figure someone from Mono is already doing this, or at least putting thought into it.  There is a SysLogAppender in log4j, but I am not clear on whether it is implemented in log4net?  The doc is here: &lt;br&gt;&lt;a target="_new" href="http://logging.apache.org/log4j/docs/api-1.3/org/apache/log4j/net/SyslogAppender.html"&gt;http://logging.apache.org/log4j/docs/api-1.3/org/apache/log4j/net/SyslogAppender.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;but the features page does not list Syslog. &lt;br&gt;&lt;a target="_new" href="http://logging.apache.org/log4net/release/features.html"&gt;http://logging.apache.org/log4net/release/features.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;It does, however, list the UdpAppender.  There is only a very small leap to go from UdpAppender to SyslogAppender. Maybe they are the same. &lt;br&gt;&lt;br&gt;Also there is the Enterprise Instrumentation Framework, or EIF, and the logging block (&lt;a target="_new" href="http://msdn.microsoft.com/library/en-us/dnpag/html/Logging.asp"&gt;http://msdn.microsoft.com/library/en-us/dnpag/html/Logging.asp&lt;/a&gt; ).  To use the Logging Block, you'd need to build a Syslog sink, which is like a syslog appender for log4net.  Again, it shouldn't be difficult.  &lt;br&gt;&lt;br&gt;</description></item><item><title>re: .NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx#9769489</link><pubDate>Wed, 17 Jun 2009 17:30:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9769489</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I'm getting the exception when the udp connection is opened:&lt;/p&gt;
&lt;p&gt;+		ex1	{&amp;quot;The requested address is not valid in its context 127.0.0.1:514&amp;quot;}	System.Exception {System.Net.Sockets.SocketException}&lt;/p&gt;
&lt;p&gt;I'm running kiwi Syslog Service on the same box, (configured for udp port 514). &amp;nbsp;Local firewalls are turned off. &lt;/p&gt;
&lt;p&gt;any suggestions?&lt;/p&gt;
</description></item><item><title>re: .NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx#9842842</link><pubDate>Tue, 21 Jul 2009 07:36:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9842842</guid><dc:creator>Dave Bartlett</dc:creator><description>&lt;p&gt;This is a very useful piece of code, thanks for your good work.&lt;/p&gt;
&lt;p&gt;I've modified your Send() method to include client IP and timestamp in the message header, so I thought I'd share:&lt;/p&gt;
&lt;p&gt;public void Send(Message message)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!helper.IsActive)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;helper.Connect(_syslogServerIp, _port);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (helper.IsActive)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int priority = message.Facility * 8 + message.Level;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string msg = System.String.Format(&amp;quot;&amp;lt;{0}&amp;gt;{1} {2} {3}&amp;quot;,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; priority,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DateTime.Now.ToString(&amp;quot;MMM dd HH:mm:ss&amp;quot;),&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ipLocalEndPoint.Address,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message.Text);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byte[] bytes = System.Text.Encoding.ASCII.GetBytes(msg);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;helper.Send(bytes, bytes.Length);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else throw new Exception(&amp;quot;Syslog client Socket is not connected. Please set the host IP&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
</description></item><item><title>re: .NET and Syslog?</title><link>http://blogs.msdn.com/dotnetinterop/archive/2004/11/05/net-and-syslog.aspx#9847254</link><pubDate>Fri, 24 Jul 2009 08:26:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9847254</guid><dc:creator>DotNetInterop</dc:creator><description>&lt;p&gt;Thanks Dave, I've included your updates into the source in the article. &lt;/p&gt;
</description></item></channel></rss>