{"id":1487,"date":"2010-11-05T18:51:27","date_gmt":"2010-11-05T16:51:27","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1487"},"modified":"2017-11-02T12:00:43","modified_gmt":"2017-11-02T10:00:43","slug":"logging-in-ftp-dll","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/logging-in-ftp-dll","title":{"rendered":"Logging in Ftp.dll"},"content":{"rendered":"<p>To enable logging for Ftp.dll <a href=\"\/ftp\">.NET FTP and FTPS component<\/a> you only need to add the following line before you connect:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version:\r\n\r\nLimilabs.FTP.Log.Enabled = true;\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version:\r\n\r\nLimilabs.FTP.Log.Enabled = True\r\n\r\n<\/pre>\n<p>You can observe the log output by:\t<\/p>\n<ul>\n<li>looking at the Visual Studio&#8217;s <strong>output window<\/strong> (View\/Output\/&#8217;Show output from&#8217;: Debug)<\/li>\n<li>subscribing to <em>Log.WriteLine<\/em> event<\/li>\n<li>defining custom listeners using your application&#8217;s config file (App.config or Web.config)<\/li>\n<li>using log4net<\/li>\n<\/ul>\n<p>This is how the log looks like in the Visual Studio&#8217;s output window:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"516\" height=\"682\" src=\"\/blog\/wp-content\/uploads\/2010\/11\/ftp_log.png\" alt=\"\" title=\"Ftp log\" class=\"aligncenter size-full wp-image-1493\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2010\/11\/ftp_log.png 516w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2010\/11\/ftp_log-226x300.png 226w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/p>\n<p>You can also enable logging using your application&#8217;s config file (App.config, Web.config):<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;\r\n&lt;configuration&gt;\r\n    &lt;system.diagnostics&gt;\r\n\r\n      &lt;switches&gt;\r\n        &lt;add name=&quot;Ftp.dll&quot; value=&quot;Verbose&quot; \/&gt;\r\n      &lt;\/switches&gt;\r\n\r\n    &lt;\/system.diagnostics&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<h2>log4net<\/h2>\n<p>If you are using the latest version of log4net.dll, Ftp.dll is going to use log4net instead of standard .NET <em>System.Net.TraceSource<\/em> class. Please refer to log4net manual on how to capture log entries.<\/p>\n<p>Ftp.dll uses<strong> logger called &#8220;Ftp.dll&#8221;<\/strong> (_logger = LogManager.GetLogger(&#8220;Ftp.dll&#8221;)) and <strong>level Info<\/strong> (_logger.Info(message)) to log information.<\/p>\n<p>Please remember that even when using log4net, you need to enable logging by setting &#8220;Limilabs.FTP.Log.Enabled = True&#8221; or by setting <em>Ftp.dll<\/em> trace switch in the config file (App.config, Web.config) to <em>Verbose<\/em> as shown above.<\/p>\n<h2>Log to file<\/h2>\n<p>You&#8217;ll need to define a <em>TextWriterTraceListener<\/em> that writes to a file and connect it with Ftp.dll trace source. The easiest solution is to modify your application&#8217;s config file (App.config, Web.config) accordingly:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;\r\n&lt;configuration&gt;\r\n    &lt;system.diagnostics&gt;\r\n\r\n        &lt;trace autoflush=&quot;true&quot;\/&gt;\r\n   \r\n        &lt;switches&gt;\r\n            &lt;add name=&quot;Ftp.dll&quot; value=&quot;Verbose&quot;\/&gt;\r\n        &lt;\/switches&gt;\r\n   \r\n        &lt;sources&gt;\r\n            &lt;source name=&quot;Ftp.dll&quot;&gt;\r\n                &lt;listeners&gt;\r\n                    &lt;add name=&quot;FtpLogFile&quot;\/&gt;\r\n                &lt;\/listeners&gt;\r\n            &lt;\/source&gt;\r\n        &lt;\/sources&gt;\r\n   \r\n        &lt;sharedListeners&gt;\r\n            &lt;add \r\n                name=&quot;FtpLogFile&quot; \r\n                type=&quot;System.Diagnostics.TextWriterTraceListener&quot; \r\n                initializeData=&quot;c:\\folder-with-write-access\\ftp.log&quot;\/&gt;\r\n        &lt;\/sharedListeners&gt;\r\n\r\n    &lt;\/system.diagnostics&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<h2>Log.WriteLine<\/h2>\n<p><em>Log<\/em> class exposes <em>WriteLine<\/em> event. You can use that event to subscribe your own logging library.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nLimilabs.FTP.Log.WriteLine += Console.WriteLine;\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nLimilabs.FTP.Log.WriteLine += Console.WriteLine\r\n<\/pre>\n<p>You can <a href=\"\/ftp\">download Ftp.dll FTP\/FTPS client for .NET here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To enable logging for Ftp.dll .NET FTP and FTPS component you only need to add the following line before you connect: \/\/ C# version: Limilabs.FTP.Log.Enabled = true; &#8216; VB.NET version: Limilabs.FTP.Log.Enabled = True You can observe the log output by: looking at the Visual Studio&#8217;s output window (View\/Output\/&#8217;Show output from&#8217;: Debug) subscribing to Log.WriteLine event [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[22,80,24,32],"class_list":["post-1487","post","type-post","status-publish","format-standard","hentry","category-ftp-dll","tag-ftp","tag-ftp-component","tag-ftps","tag-log4net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1487"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=1487"}],"version-history":[{"count":12,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1487\/revisions"}],"predecessor-version":[{"id":5371,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1487\/revisions\/5371"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}