{"id":10094,"date":"2015-04-30T13:35:15","date_gmt":"2015-04-30T13:35:15","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=10094"},"modified":"2024-12-12T07:01:45","modified_gmt":"2024-12-12T07:01:45","slug":"create-log-file-using-net-api","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/","title":{"rendered":"Create log file using .net API"},"content":{"rendered":"<p style=\"text-align: justify;\">Whenever we implement complex routines like uploading data etc., one major thing comes into the picture is creating log of each action performed in the routine. Logs are something which tells users where the process failed and what is the error. In case of Sage CRM, we often develop complex routines for which error logging is one of the most important factor which needs to be taken care of.<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #993300;\"><em><strong>New\u00a0Post:<\/strong><\/em><\/span>\u00a0<a title=\"Save time with Case Suggestions on Customer Portal\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/29\/save-time-with-case-suggestions-on-customer-portal\/\" target=\"_blank\" rel=\"noopener\">Save time with Case Suggestions on Customer Portal<\/a><\/p>\n<p style=\"text-align: justify;\">Now, how to create logs? Using custom methods..?? Answer in NO. Here in this blog I will be explaining a simplest way to create log file for your custom routine implemented using Sage CRM .net API.<\/p>\n<p style=\"text-align: justify;\">Sage CRM .Net API provides wide range of built in functions which reduces lot of time and provides better flexibility while implementation. There is a method named LogMessage in .Net API. This method can be used in three ways as shown below.<\/p>\n<p style=\"text-align: justify;\"><strong>1.<\/strong> LogMessage(string message);<br \/>\n<strong>2.<\/strong> LogMessage(string message, int level);<br \/>\n<strong>3.<\/strong> LogMessage(string filename, string message, int level)<\/p>\n<p style=\"text-align: justify;\">As shown above, different parameters can be passed to this method as per convenience. I would suggest to use the third syntax.<\/p>\n<p style=\"text-align: justify;\">Let\u2019s see an example of this. I have created a simple list page and below is the code snippet of the page. I have called this List under MyCRM context by adding a tab.<\/p>\n<p>&lt;snippet&gt;<br \/>\nclass ProjectsList:ListPage<br \/>\n{<br \/>\npublic ProjectsList()<br \/>\n: base(&#8220;Projects&#8221;, &#8221; ProjectsList &#8220;, &#8220;ProjectsFilterBox&#8221;)<br \/>\n{<br \/>\nint sUserId = 0;<br \/>\nsUserId = CurrentUser.UserId;<br \/>\nLogMessage(&#8220;DotNetRoutineLogs&#8221;, &#8220;&#8212; Log for list page Start &#8212;&#8220;, 1);<br \/>\nLogMessage(&#8220;DotNetRoutineLogs&#8221;, &#8220;&#8212; Log important messages\/errors here &#8212;&#8220;, 1);<br \/>\nthis.ResultsGrid.Filter = &#8220;proj_assigneduserid=&#8221; + sUserId.ToString();<br \/>\nLogMessage(&#8220;DotNetRoutineLogs&#8221;, &#8220;&#8212; Log for list page End &#8212;&#8220;, 1);<br \/>\n}<br \/>\n}<br \/>\n&lt;\/snippet&gt;<\/p>\n<p style=\"text-align: justify;\">Now, when your page runs, a log file with the same name as specified in the method will be created in the Logs folder of CRM directory. You can see in the below screenshot that, a log file named DotNetRoutineLogs is created.<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter  wp-image-10095\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\" alt=\"Image-1\" width=\"795\" height=\"402\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">You can use logging level by specifying level while writing the log. I have explained this with a simple example. This can be surely used in better way for complex implementations.<\/p>\n<p style=\"text-align: justify;\">Now, as this log file gets created in Logs folder then, how user will access it? Below is the blog link where you will get to know how to configure logs.<\/p>\n<p style=\"text-align: justify;\"><a title=\"How log files are maintained in Sage CRM\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/23\/how-log-files-are-maintained-in-sage-crm\/\" target=\"_blank\" rel=\"noopener\">How log files are maintained in Sage CRM<\/a><\/p>\n<p style=\"text-align: justify;\">Isn\u2019t it a pretty simple? Happy Coding..!!!<\/p>\n<p style=\"text-align: justify;\"><em><strong><span style=\"color: #993300;\">Also Read:<\/span><\/strong><\/em><\/p>\n<p style=\"text-align: justify;\"><strong>1.<\/strong> <a title=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/28\/boost-knowledge-base-with-download-links-in-customer-portal\/\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/28\/boost-knowledge-base-with-download-links-in-customer-portal\/\" target=\"_blank\" rel=\"noopener\" data-wplink-edit=\"true\">Boost Knowledge Base with Download links in Customer Portal<\/a><br \/>\n<strong>2.<\/strong> <a title=\"Managing Knowledge Base in the Self Service Portal\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/24\/managing-knowledge-base-in-the-self-service-portal\/\" target=\"_blank\" rel=\"noopener\">Managing Knowledge Base in the Self Service Portal<\/a><br \/>\n<strong>3.<\/strong> <a title=\"File Downloads in Self Service Portal\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/22\/file-downloads-in-self-service-portal\/\" target=\"_blank\" rel=\"noopener\">File Downloads in Self Service Portal<\/a><br \/>\n<strong>4.<\/strong> <a title=\"Integrate CRM Self Service Portal with Sage CRM\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/20\/integrate-crm-self-service-portal-with-sage-crm\/\" target=\"_blank\" rel=\"noopener\">Integrate CRM Self Service Portal with Sage CRM<\/a><br \/>\n<strong>5.<\/strong> <a title=\"Identify the version in Sage CRM Cloud\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/03\/31\/identify-the-version-in-sagecrm-com\/\" target=\"_blank\" rel=\"noopener\">Identify the version in Sage CRM Cloud<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whenever we implement complex routines like uploading data etc., one major thing comes into the picture is creating log of each action performed in the routine. Logs are something which tells users where the process failed and what is the error. In case of Sage CRM, we often develop complex routines for which error logging\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,94,230,332,352,1],"tags":[446,869,1548],"class_list":["post-10094","post","type-post","status-publish","format-standard","hentry","category-net-api","category-custom-logs","category-maintenance","category-sage-crm","category-script","category-uncategorized","tag-net-api","tag-custom-logs","tag-logs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"Whenever we implement complex routines like uploading data etc., one major thing comes into the picture is creating log of each action performed in the routine. Logs are something which tells users where the process failed and what is the error. In case of Sage CRM, we often develop complex routines for which error logging\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-30T13:35:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-12T07:01:45+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\" \/>\n<meta name=\"author\" content=\"greysagecrm\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"greysagecrm\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\",\"name\":\"Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\",\"datePublished\":\"2015-04-30T13:35:15+00:00\",\"dateModified\":\"2024-12-12T07:01:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage\",\"url\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\",\"contentUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create log file using .net API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\",\"name\":\"Sage CRM \u2013 Tips, Tricks and Components\",\"description\":\"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\",\"name\":\"greysagecrm\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"caption\":\"greysagecrm\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/","og_locale":"en_US","og_type":"article","og_title":"Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components","og_description":"Whenever we implement complex routines like uploading data etc., one major thing comes into the picture is creating log of each action performed in the routine. Logs are something which tells users where the process failed and what is the error. In case of Sage CRM, we often develop complex routines for which error logging\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2015-04-30T13:35:15+00:00","article_modified_time":"2024-12-12T07:01:45+00:00","og_image":[{"url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg","type":"","width":"","height":""}],"author":"greysagecrm","twitter_card":"summary_large_image","twitter_misc":{"Written by":"greysagecrm","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/","name":"Create log file using .net API - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage"},"image":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage"},"thumbnailUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg","datePublished":"2015-04-30T13:35:15+00:00","dateModified":"2024-12-12T07:01:45+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#primaryimage","url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg","contentUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2015\/04\/Image-1.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2015\/04\/30\/create-log-file-using-net-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"Create log file using .net API"}]},{"@type":"WebSite","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/","name":"Sage CRM \u2013 Tips, Tricks and Components","description":"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f","name":"greysagecrm","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","caption":"greysagecrm"},"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/10094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/comments?post=10094"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/10094\/revisions"}],"predecessor-version":[{"id":28976,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/10094\/revisions\/28976"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=10094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=10094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=10094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}