{"id":32,"date":"2017-03-23T16:48:00","date_gmt":"2017-03-23T21:48:00","guid":{"rendered":"https:\/\/www.chrystalsander.com\/blog\/?p=32"},"modified":"2023-07-27T12:15:43","modified_gmt":"2023-07-27T17:15:43","slug":"net-using-a-single-log4net-configuration-file-across-a-multi-tier-web-application","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=32","title":{"rendered":".NET:  Using A Single log4net Configuration File Across A Multi-Tier Web Application"},"content":{"rendered":"<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\"><a href=\"https:\/\/logging.apache.org\/log4net\/\" target=\"_blank\" rel=\"noopener\"><b>log4net <\/b><\/a>is<br \/>\na tool to help the programmer output log statements to a variety of output<br \/>\ntargets.<\/span><\/div>\n<p><span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<\/p>\n<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\">This<br \/>\nexample is written in Visual Studio 2015 for a WebAPI2 solution.&nbsp; The sample solution consists of three projects<br \/>\nthat include a project for data, models, unit tests, etc. &nbsp;Source code can be found here:<o:p><\/o:p><\/span><br \/>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\"><a href=\"https:\/\/www.blogger.com\/goog_694533355\"><br \/><\/a><\/span><br \/>\n<span lang=\"EN\" style=\"color: #333333; line-height: 107%;\"><a href=\"https:\/\/github.com\/cjsander\/Log4netInMultiTierWebApp\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cjsander\/Log4netInMultiTierWebApp<\/a><\/span><\/div>\n<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\"><br \/><\/span><\/div>\n<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\"><b>SETUP:<\/b><o:p><\/o:p><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"color: #333333; line-height: 107%;\">1.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>\n<\/span><\/span><!--[endif]--><span lang=\"EN\" style=\"color: #333333; line-height: 107%;\">Create<br \/>\nyour project and then import the following Nuget package: &nbsp; &nbsp; &nbsp; &nbsp;<\/span><a href=\"https:\/\/www.nuget.org\/packages\/log4net\/\" target=\"_blank\" rel=\"noopener\"><span style=\"line-height: 107%;\">https:\/\/www.nuget.org\/packages\/log4net\/<\/span><\/a><span style=\"line-height: 107%;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"color: #333333; line-height: 107%;\">2.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>\n<\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">For<br \/>\neach project, add reference to log4net.dll assembly.&nbsp; Though all configuration will be in the &nbsp;main<br \/>\nAPI project, other projects will require the assembly reference as well.<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"color: #333333; line-height: 107%;\">3.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>\n<\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Configuration<br \/>\nfiles to be included are: <o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">a.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Log4net.config<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">b.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Web.config<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">c.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Settings.xml<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">d.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Global.asax.cs<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"color: #333333; line-height: 107%;\">4.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>\n<\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Note<br \/>\nthat the &lt;appsettings&gt; node of the web.config file has been abstracted<br \/>\ninto a separate file &#8212; Settings.xml.&nbsp;&nbsp;<br \/>\nThese settings will be referenced in the web.config in the following<br \/>\nline of code:<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<span style=\"font-family: inherit; line-height: 107%;\"><br \/><\/span><\/div>\n<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\"><\/p>\n<p><\/span><\/div>\n<div>\n<span style=\"color: blue; line-height: 107%;\"><span style=\"font-family: inherit;\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\">&nbsp;&lt;<\/span><\/span><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: #a31515; line-height: 107%;\">appSettings<\/span><span style=\"color: blue; line-height: 107%;\"> <\/span><span style=\"color: red; line-height: 107%;\">file<\/span><span style=\"color: blue; line-height: 107%;\">=<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><span style=\"color: blue; line-height: 107%;\">c:webappslog4sampleconfigsettings.xml<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><span style=\"color: blue; line-height: 107%;\">\/&gt;<\/span><span style=\"line-height: 107%;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div>\n<span style=\"color: blue; font-family: inherit; line-height: 107%;\"><br \/><\/span><\/div>\n<div>\n<span style=\"font-family: inherit; line-height: 107%;\"><b>APPLICATION:<\/b><o:p><\/o:p><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">1.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">In your web.config file, enter the<br \/>\nfollowing:<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"color: blue; font-family: inherit;\">&nbsp; <\/span><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-size: 9.0pt;\">&lt;<\/span><span style=\"color: #a31515; font-size: 9.0pt;\">configSections<\/span><span style=\"color: blue; font-size: 9.0pt;\">&gt;<\/span><span style=\"font-size: 9pt;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-size: 9.0pt;\">&nbsp;&nbsp; <a href=\"https:\/\/www.blogger.com\/null\" name=\"OLE_LINK2\"><\/a><a href=\"https:\/\/www.blogger.com\/null\" name=\"OLE_LINK1\">&nbsp;&lt;<\/a><\/span><span style=\"color: #a31515; font-size: 9.0pt;\">section<\/span><span style=\"color: blue; font-size: 9.0pt;\"> <\/span><span style=\"color: red; font-size: 9.0pt;\">name<\/span><span style=\"color: blue; font-size: 9.0pt;\">=<\/span><span style=\"font-size: 9pt;\">&#8220;<\/span><span style=\"color: blue; font-size: 9.0pt;\">log4net<\/span><span style=\"font-size: 9pt;\">&#8220;<\/span><span style=\"color: blue; font-size: 9.0pt;\"> <\/span><span style=\"color: red; font-size: 9.0pt;\">type<\/span><span style=\"color: blue; font-size: 9.0pt;\">=<\/span><span style=\"font-size: 9pt;\">&#8220;<\/span><span style=\"color: blue; font-size: 9.0pt;\">log4net.Config.Log4NetConfigurationSectionHandler,<br \/>\nlog4net<\/span><span style=\"font-size: 9pt;\">&#8220;<\/span><span style=\"color: blue; font-size: 9.0pt;\">\/&gt;<\/span><span style=\"font-size: 9pt;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; line-height: 107%;\">&nbsp; &lt;\/<\/span><span style=\"color: #a31515; line-height: 107%;\">configSections<\/span><span style=\"color: blue; line-height: 107%;\">&gt;<\/span><\/span><span style=\"font-family: inherit; line-height: 107%;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">2.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Now, add the logging configuration<br \/>\nvalues.&nbsp; These can be added in your<br \/>\nweb.config(or app.config) but in this scenario, it has its own configuration<br \/>\nfile \u2013 log4net.config:<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-size: 9.0pt;\">&lt;<\/span><span style=\"font-size: 9.0pt; mso-bidi-font-family: &quot;Courier New&quot;;\">log4net<span style=\"color: blue;\">&gt;<\/span><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-size: 9.0pt;\">&nbsp;<br \/>\n&lt;<\/span><span style=\"font-size: 9.0pt; mso-bidi-font-family: &quot;Courier New&quot;;\">appender<span style=\"color: blue;\"> <\/span><span style=\"color: red;\">name<\/span><span style=\"color: blue;\">=<\/span>&#8220;<span style=\"color: blue;\">RollingFile<\/span>&#8220;<span style=\"color: blue;\"> <\/span><span style=\"color: red;\">type<\/span><span style=\"color: blue;\">=<\/span>&#8220;<span style=\"color: blue;\">log4net.Appender.RollingFileAppender<\/span>&#8220;<span style=\"color: blue;\">&gt;\u2026..<o:p><\/o:p><\/span><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"color: blue; font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small; mso-bidi-font-family: &quot;Courier New&quot;;\">&lt;\/<\/span><span style=\"font-size: 9.0pt; mso-bidi-font-family: &quot;Courier New&quot;;\"><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\">log4net<\/span><span style=\"color: blue;\"><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\">&gt;<\/span><span style=\"font-family: inherit;\"><o:p><\/o:p><\/span><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit;\"><br \/><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">3.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">Then,<br \/>\nyou will want to add the path to the file in your &lt;appSettings&gt; node:<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; line-height: 107%;\">&lt;<\/span><span style=\"color: #a31515; line-height: 107%;\">add<\/span><span style=\"color: blue; line-height: 107%;\"> <\/span><span style=\"color: red; line-height: 107%;\">key<\/span><span style=\"color: blue; line-height: 107%;\">=<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><span style=\"color: blue; line-height: 107%;\">logPath<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><span style=\"color: blue; line-height: 107%;\"> <\/span><span style=\"color: red; line-height: 107%;\">value<\/span><span style=\"color: blue; line-height: 107%;\">=<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><span style=\"color: blue; line-height: 107%;\">c:webappslog4sampleconfiglog4net.config<\/span><span style=\"line-height: 107%;\">&#8220;<\/span><\/span><span style=\"color: blue; line-height: 107%;\"><span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"> \/&gt;<\/span><span style=\"font-family: inherit;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"mso-list: l0 level1 lfo1; text-indent: -.25in;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\">4.<span style=\"font-stretch: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><!--[endif]--><span style=\"line-height: 107%;\">In your<br \/>\nGlobal.asax file, add the following to the Application_Start() method:<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: green; font-size: 9.0pt;\">\/\/log4net setup:<\/span><span style=\"font-size: 9pt;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-size: 9.0pt;\">var<\/span><span style=\"font-size: 9pt;\"> logPath = (<\/span><span style=\"color: #2b91af; font-size: 9.0pt;\">ConfigurationManager<\/span><span style=\"font-size: 9pt;\">.AppSettings[<\/span><span style=\"color: #a31515; font-size: 9.0pt;\">&#8220;logPath&#8221;<\/span><span style=\"font-size: 9pt;\">]);<o:p><\/o:p><\/span><\/span><\/div>\n<div>\n<span style=\"color: blue; font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small; line-height: 107%;\"><\/p>\n<p><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"line-height: 107%;\">log4net.Config.<\/span><span style=\"color: #2b91af; line-height: 107%;\">XmlConfigurator<\/span><span style=\"line-height: 107%;\">.ConfigureAndWatch(<\/span><span style=\"color: blue; line-height: 107%;\">new<\/span><span style=\"line-height: 107%;\"> <\/span><span style=\"color: #2b91af; line-height: 107%;\">FileInfo<\/span><span style=\"line-height: 107%;\">(logPath));<\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit;\"><br \/><\/span><\/div>\n<div>\n<span style=\"font-family: inherit; line-height: 107%;\"><b>EXTRA:<\/b><o:p><\/o:p><\/span><\/div>\n<div>\n<span style=\"font-family: inherit; line-height: 107%;\">You can also<br \/>\nadd a helper method to customize your logging and add details that would help<br \/>\nwith your debugging:<o:p><\/o:p><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">public<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">class<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> <\/span><span style=\"color: #2b91af; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">Log4NetHelper<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\">&nbsp;&nbsp;&nbsp; {<o:p><\/o:p><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">public<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">string<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> LogMsg(<\/span><span style=\"color: #2b91af; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">Message<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> m, [<\/span><span style=\"color: #2b91af; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">Optional<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">] <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">string<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> exceptionMsg, [<\/span><span style=\"color: #2b91af; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">CallerMemberName<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">] <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">string<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> methodName = <\/span><span style=\"color: #a31515; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">&#8220;&#8221;<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">)<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p><\/o:p><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">string<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> msg = <\/span><span style=\"color: #a31515; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">$&#8221;<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">{methodName}<\/span><span style=\"color: #a31515; font-family: &quot;consolas&quot;; font-size: 8.0pt;\"> <\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">{m}<\/span><span style=\"color: #a31515; font-family: &quot;consolas&quot;; font-size: 8.0pt;\"> <\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">{exceptionMsg}<\/span><span style=\"color: #a31515; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">&#8220;<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">;<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue; font-family: &quot;consolas&quot;; font-size: 8.0pt;\">return<\/span><span style=\"font-family: &quot;consolas&quot;; font-size: 8pt;\"> msg;<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small; line-height: 107%;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small; line-height: 107%;\">}<\/span><span style=\"font-family: inherit; line-height: 107%;\"><o:p><\/o:p><\/span><br \/>\n<span style=\"font-family: inherit; line-height: 107%;\"><br \/><\/span><\/div>\n<div>\n<span lang=\"EN\" style=\"color: #333333; font-family: inherit; line-height: 107%;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To<br \/>\nreference:<\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"color: blue; font-family: &quot;courier new&quot;; font-size: 9.0pt;\">private<\/span><span style=\"font-family: &quot;courier new&quot;; font-size: 9pt;\"> <\/span><span style=\"color: blue; font-family: &quot;courier new&quot;; font-size: 9.0pt;\">readonly<\/span><span style=\"font-family: &quot;courier new&quot;; font-size: 9pt;\"> <\/span><span style=\"font-family: &quot;courier new&quot;; font-size: 9.0pt;\">Log4NetHelper _msg = <span style=\"color: blue;\">new<\/span> Log4NetHelper();<o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace; font-size: x-small;\"><span style=\"font-family: &quot;courier new&quot;; font-size: 9pt;\">_logger.Debug(_msg.LogMsg(<\/span><span style=\"font-family: &quot;courier new&quot;; font-size: 9.0pt;\">Log4NetHelper.Message.InitialRequestStart));<\/span><\/span><span lang=\"EN\" style=\"color: #333333; font-family: inherit;\"><o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<b><span style=\"font-family: inherit;\">SAMPLE FOLDER STRUCTURE:<\/span><\/b><br \/>\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<\/p>\n<div style=\"clear: both; text-align: center;\">\n<a href=\"https:\/\/3.bp.blogspot.com\/-PgMtLmUcxO0\/WNRBXTGIJ7I\/AAAAAAAABeE\/AmjXMu5Iq08Yh89VNDsUyT4A5XdMbat0QCLcB\/s1600\/2.jpg\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"><\/a><a href=\"https:\/\/3.bp.blogspot.com\/-PgMtLmUcxO0\/WNRBXTGIJ7I\/AAAAAAAABeE\/AmjXMu5Iq08Yh89VNDsUyT4A5XdMbat0QCLcB\/s1600\/2.jpg\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"><span style=\"font-family: inherit;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" height=\"153\" src=\"https:\/\/3.bp.blogspot.com\/-PgMtLmUcxO0\/WNRBXTGIJ7I\/AAAAAAAABeE\/AmjXMu5Iq08Yh89VNDsUyT4A5XdMbat0QCLcB\/s320\/2.jpg\" width=\"320\" \/><\/span><\/a><a href=\"https:\/\/1.bp.blogspot.com\/-adn1hM-6P3M\/WNRBXTZOZWI\/AAAAAAAABeA\/l-BdVLcBN38HrU2UfTT12fXN9-3o3H1BACLcB\/s1600\/1.jpg\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"><span style=\"font-family: inherit;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-adn1hM-6P3M\/WNRBXTZOZWI\/AAAAAAAABeA\/l-BdVLcBN38HrU2UfTT12fXN9-3o3H1BACLcB\/s1600\/1.jpg\" \/><\/span><\/a><\/div>\n<p>\n<span style=\"font-family: inherit;\"><br \/><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit;\"><br \/><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><\/div>\n<div style=\"margin-left: .5in;\">\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<b><span style=\"font-family: inherit;\">FURTHER REFERENCES:<\/span><\/b><\/p>\n<div>\n<span style=\"font-family: inherit;\"><span style=\"line-height: 107%;\"><a href=\"http:\/\/geekswithblogs.net\/michaelstephenson\/archive\/2014\/01\/02\/155044.aspx\" target=\"_blank\" rel=\"noopener\">http:\/\/geekswithblogs.net\/michaelstephenson\/archive\/2014\/01\/02\/155044.aspx<\/a><\/span><span style=\"line-height: 107%;\"><o:p><\/o:p><\/span><\/span><\/div>\n<p><\/p>\n<div>\n<span style=\"font-family: inherit;\"><a href=\"https:\/\/logging.apache.org\/log4net\/release\/config-examples.html\" target=\"_blank\" rel=\"noopener\"><span style=\"line-height: 107%;\">https:\/\/logging.apache.org\/log4net\/release\/config-examples.html<\/span><\/a><span style=\"line-height: 107%;\"><o:p><\/o:p><\/span><\/span><\/div>\n<p><span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit; font-size: 9.0pt;\"><br \/><\/span><br \/>\n<span style=\"font-family: &quot;courier new&quot;; font-size: 9.0pt;\"><br \/><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>log4net is a tool to help the programmer output log statements to a variety of output targets. This example is written in Visual Studio 2015 for a WebAPI2 solution.&nbsp; The sample solution consists of three projects that include a project for data, models, unit tests, etc. &nbsp;Source code can be found here: https:\/\/github.com\/cjsander\/Log4netInMultiTierWebApp SETUP: 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=32\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;.NET:  Using A Single log4net Configuration File Across A Multi-Tier Web Application&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,4,92,17],"tags":[42],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/32"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":1,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/206"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}