{"id":161,"date":"2007-05-19T11:50:54","date_gmt":"2007-05-19T16:50:54","guid":{"rendered":"\/cgi\/wp\/?p=161"},"modified":"2019-12-11T08:53:46","modified_gmt":"2019-12-11T13:53:46","slug":"log4net-with-aspnet-11","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=161","title":{"rendered":"log4net With ASP.NET 1.1"},"content":{"rendered":"<div class=\"entry\">\n<p><strong>log4net <\/strong>provides the same sort of debug and trace logging capabilities as the trace listeners in ASP.NET 2.0 but it can be used in ASP.NET 1.1. Therefore if you like trace listeners in ASP.NET 2.0 but have some ASP.NET 1.1 web applications that you cannot upgrade, you should give log4net a try.<\/p>\n<p>The log4net web page can be found at: <a title=\"http:\/\/logging.apache.org\/log4net\/\" href=\"http:\/\/logging.apache.org\/log4net\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/logging.apache.org\/log4net\/<\/a> You will also need the <strong>NAnt<\/strong> build tool from <a title=\"http:\/\/nant.sourceforge.net\/\" href=\"http:\/\/nant.sourceforge.net\/\">http:\/\/nant.sourceforge.net\/<\/a><\/p>\n<p>Here are the steps to get started with log4net:<\/p>\n<ol>\n<li>Download NAnt, the free .NET build tool.<\/li>\n<li>Extract the contents of the archive to the location you wish to install C:\\Program Files\\NAnt<\/li>\n<li>Edit log4net-1.2.10 build.cmd file. Remove nant-0.85-nightly-2006-03-06 from line 21.<\/li>\n<li>Run the SN utility from the .NET Framework SDK as follows: <strong>sn -k log4net.snk<\/strong><\/li>\n<li>Copy <strong>log4net.snk<\/strong> to log4net-1.2.10 directory<\/li>\n<li>Run <strong>build.cmd<\/strong> from command line<\/li>\n<li>Copy <strong>log4net.dll<\/strong> and <strong>log4net.xml<\/strong> files from log4net-1.2.10\\bin\\net\\1.1\\release to bin directory<\/li>\n<li>Add configSection to web.config file. <strong><em>The version number is the most troublesome aspect. It may not be required or you may need to get the exact string from the output window error messages!<\/em><\/strong><\/li>\n<li>Add section to web.config<\/li>\n<li>Add Reference to log4net<\/li>\n<li>Add classes to Imports<br \/>\n<span style=\"color: #0000ff; font-size: small;\">Imports<\/span><span style=\"font-size: small;\"> log4net <\/span><span style=\"color: #0000ff; font-size: small;\"><br \/>\nImports<\/span><span style=\"font-size: small;\"> log4net.Config<\/span><\/li>\n<li>Declare a logger object<br \/>\n<span style=\"color: #0000ff; font-size: small;\">Private<\/span> <span style=\"color: #0000ff; font-size: small;\">Shared<\/span> <span style=\"color: #0000ff; font-size: small;\">ReadOnly<\/span><span style=\"font-size: small;\"> log <\/span><span style=\"color: #0000ff; font-size: small;\">As<\/span><span style=\"font-size: small;\"> ILog = LogManager.GetLogger(<\/span><span style=\"color: #0000ff; font-size: small;\">GetType<\/span><span style=\"font-size: small;\">(WebForm1))<\/span><\/li>\n<li>Add some Debug and Info statements to generate some output<br \/>\n<span style=\"color: #0000ff; font-size: small;\">If<\/span><span style=\"font-size: small;\"> log.IsDebugEnabled <\/span><span style=\"color: #0000ff; font-size: small;\">Then<\/span><span style=\"font-size: small;\"> log.Debug(&#8220;Debug is enabled. Page_Load subroutine.&#8221;)<br \/>\n<\/span><span style=\"color: #0000ff; font-size: small;\">If<\/span><span style=\"font-size: small;\"> log.IsInfoEnabled <\/span><span style=\"color: #0000ff; font-size: small;\">Then<\/span><span style=\"font-size: small;\"> log.Info(&#8220;Info is enabled. Page_Load subroutine.&#8221;)<\/span><\/li>\n<li>Make sure the web root has write permissions for ASPNET network account<\/li>\n<li>Add line of code to <strong>global.asa.vb <\/strong>file in Sub Application_Start. Make sure to include <span style=\"color: #0000ff;\">Imports<\/span> log4net in <strong>global.asa.vb<br \/>\n<\/strong>log4net.Config.XmlConfigurator.Configure()<\/li>\n<li>Add Assembly line to <strong>AssemblyInfo.vb<\/strong> <span style=\"font-size: small;\">&lt;<\/span><span style=\"color: #0000ff; font-size: small;\">Assembly<\/span><span style=\"font-size: small;\">: log4net.Config.XmlConfigurator(ConfigFileExtension:=&#8221;log4net&#8221;, Watch:=<\/span><span style=\"color: #0000ff; font-size: small;\">True<\/span><span style=\"font-size: small;\">)&gt;<\/span><\/li>\n<\/ol>\n<p>log4net offers a few options that trace listeners don&#8217;t provide such as the ability to log trace and debug output to an Access database.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>log4net provides the same sort of debug and trace logging capabilities as the trace listeners in ASP.NET 2.0 but it can be used in ASP.NET 1.1. Therefore if you like trace listeners in ASP.NET 2.0 but have some ASP.NET 1.1 &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=161\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=161"}],"version-history":[{"count":2,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":3440,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/3440"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}