{"id":73,"date":"2016-01-31T14:01:09","date_gmt":"2016-01-31T14:01:09","guid":{"rendered":"http:\/\/windows.emacslisp.com\/?p=73"},"modified":"2016-01-31T14:05:06","modified_gmt":"2016-01-31T14:05:06","slug":"umbraco-start-of-source-code-analysis-with-logging-system","status":"publish","type":"post","link":"http:\/\/windows.emacslisp.com\/index.php\/2016\/01\/31\/umbraco-start-of-source-code-analysis-with-logging-system\/","title":{"rendered":"Umbraco &#8211; start of source code analysis with Logging System"},"content":{"rendered":"<p>This is first article about umbraco&#8217;s source code analysis.<br \/>\numbraco is big project using <strong>Asp.net MVC<\/strong> with 3338 cs file and lots of javascript\/css\/html.<br \/>\nNormally it is bigger than enterprise project and it will take long time to analysis it as well.<\/p>\n<p>The first part is logging module of umbraco.<\/p>\n<p>logging config is located at &#8220;umbraco.web.UI&#8221; project in &#8220;config\\log4net.config&#8221;.<br \/>\nand core class is in &#8220;umbraco.core&#8221; project in &#8220;Logging\\Loggger.cs&#8221;. lots of logger are located at &#8220;Logging&#8221; folder by the way.<\/p>\n<p>A log4net.config which C# developer is very familiar with.<\/p>\n<pre lang=\"xml\" line=\"1\">\r\n<?xml version=\"1.0\"?>\r\n<log4net>\r\n  <root>\r\n    <priority value=\"Debug\"\/>\r\n    <appender-ref ref=\"AsynchronousLog4NetAppender\" \/>\r\n  <\/root>\r\n  <appender name=\"rollingFile\" type=\"log4net.Appender.RollingFileAppender\">\r\n\t  <file type=\"log4net.Util.PatternString\" value=\"App_Data\\Logs\\UmbracoTraceLog.%property{log4net:HostName}.txt\" \/>\r\n    <lockingModel type=\"log4net.Appender.FileAppender+MinimalLock\" \/>\r\n    <appendToFile value=\"true\" \/>\r\n    <rollingStyle value=\"Date\" \/>\r\n    <maximumFileSize value=\"5MB\" \/>\r\n    <layout type=\"log4net.Layout.PatternLayout\">\r\n      <conversionPattern value=\" %date [P%property{processId}\/D%property{appDomainId}\/T%thread] %-5level %logger - %message%newline\" \/>\r\n    <\/layout>\r\n    <encoding value=\"utf-8\" \/>\r\n  <\/appender>\r\n  <appender name=\"AsynchronousLog4NetAppender\" type=\"Umbraco.Core.Logging.ParallelForwardingAppender,Umbraco.Core\">\r\n    <appender-ref ref=\"rollingFile\" \/>\r\n  <\/appender>\r\n  <!--Here you can change the way logging works for certain namespaces  -->\r\n  <logger name=\"NHibernate\">\r\n    <level value=\"WARN\" \/>\r\n  <\/logger>\r\n<\/log4net>\r\n<\/pre>\n<p>I will add some comment on this log4net config xml as well later.<\/p>\n<p>The call stack are following<\/p>\n<p>at Umbraco.Core.CoreBootManager.InitializeLoggerResolver()<br \/>\nat Umbraco.Core.CoreBootManager.Initialize()<br \/>\nat Umbraco.Web.WebBootManager.Initialize()<br \/>\nat Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e) <\/p>\n<p>InitializeLoggerResolver() source code is:<\/p>\n<pre lang=\"csharp\" line=\"1\"> \r\n        protected virtual void InitializeLoggerResolver()\r\n        {\r\n            LoggerResolver.Current = new LoggerResolver(ProfilingLogger == null ? Logger.CreateWithDefaultLog4NetConfiguration() : ProfilingLogger.Logger)\r\n            {\r\n                \/\/This is another special resolver that needs to be resolvable before resolution is frozen\r\n                \/\/since it is used for profiling the application startup\r\n                CanResolveBeforeFrozen = true\r\n            };\r\n        }\r\n<\/pre>\n<p>the key to init log4.net object and read configuration is:<\/p>\n<pre lang=\"csharp\" line=\"1\"> \r\n     Logger.CreateWithDefaultLog4NetConfiguration()\r\n<\/pre>\n<p>After LoggerResolver has been initialized, it will be added into collection inside ResolverCollection using &#8220;ResolverCollection.Add&#8221;.<\/p>\n<p>the Resolver adding is another topic. it has to call WriteLock, ReaderLock to add Resolver in thread-safe.<br \/>\nMore information will be add to next topic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is first article about umbraco&#8217;s source code analysis. umbraco is big project using Asp.net MVC with 3338 cs file and lots of javascript\/css\/html. Normally it is bigger than enterprise project and it will take long time to analysis it &hellip; <a href=\"http:\/\/windows.emacslisp.com\/index.php\/2016\/01\/31\/umbraco-start-of-source-code-analysis-with-logging-system\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/73"}],"collection":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":4,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":77,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions\/77"}],"wp:attachment":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}