{"id":887,"date":"2016-10-16T15:34:46","date_gmt":"2016-10-16T12:34:46","guid":{"rendered":"https:\/\/gokhan-gokalp.com\/?p=887"},"modified":"2019-01-10T11:22:48","modified_gmt":"2019-01-10T08:22:48","slug":"loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak","status":"publish","type":"post","link":"https:\/\/gokhan-gokalp.com\/tr\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/","title":{"rendered":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak"},"content":{"rendered":"<p>Merhaba arkada\u015flar.<\/p>\n<p>Bu makale konusunda\u00a0sizlerle uygulamalar\u0131m\u0131zda <strong>Correlation ID<\/strong> arac\u0131l\u0131\u011f\u0131 ile\u00a0consistent bir \u015fekilde nas\u0131l log&#8217;lama i\u015flemlerini ger\u00e7ekle\u015ftirebiliriz\u00a0konusunu ele almaya \u00e7al\u0131\u015faca\u011f\u0131m.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/blog-arrows.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-897 lazyload\" data-src=\"\/wp-content\/uploads\/2016\/10\/blog-arrows.png\" alt=\"blog-arrows\" width=\"250\" height=\"168\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 250px; --smush-placeholder-aspect-ratio: 250\/168;\" \/><\/a><\/p>\n<p>\u00c7o\u011fu zaman geli\u015ftirmekte oldu\u011fumuz uygulamalarda, arkaplanda neyin olup bitti\u011fini anlayabilmek i\u00e7in genelde \u00e7e\u015fitli log&#8217;lama i\u015flemlerini ger\u00e7ekle\u015ftiririz. \u00d6zellikle b\u00fcy\u00fcmekte ve\u00a0b\u00fcy\u00fck \u00e7apta olan projelerde, monolithic\u00a0architecture&#8217;lar\u0131n yerine\u00a0distributed architecture&#8217;lar\u0131n tercih edilmesiyle beraber, distributed d\u00fcnya sa\u011flam\u0131\u015f oldu\u011fu bir \u00e7ok faydan\u0131n yan\u0131nda\u00a0business process y\u00f6netimi ve consistency gibi baz\u0131 sorunlar\u0131 da beraberinde\u00a0getirmektedir.<\/p>\n<h4>Senaryo<\/h4>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/payment-logging-flow.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-894 lazyload\" data-src=\"\/wp-content\/uploads\/2016\/10\/payment-logging-flow.jpg\" alt=\"payment-logging-flow\" width=\"1192\" height=\"660\" data-srcset=\"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-flow.jpg 1192w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-flow-300x166.jpg 300w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-flow-1024x567.jpg 1024w\" data-sizes=\"(max-width: 1192px) 100vw, 1192px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1192px; --smush-placeholder-aspect-ratio: 1192\/660;\" \/><\/a><\/p>\n<p>Yukar\u0131da ki gibi\u00a0bir \u00f6rnekle a\u00e7\u0131klamak gerekirse e\u011fer:<\/p>\n<p>\u00d6rne\u011fin X request&#8217;i ilgili business i\u015flemini ger\u00e7ekle\u015ftirebilmesi i\u00e7in, -n tane service ile \u00e7al\u0131\u015fmas\u0131 gerekmektedir. Ger\u00e7ekle\u015ftirecek oldu\u011fu bu service call&#8217;lar sonucunda ise, olu\u015fturaca\u011f\u0131 bir result bulunmaktad\u0131r.<\/p>\n<p>Peki, bu service call&#8217;lar\u0131 s\u0131ras\u0131nda herhangi bir noktada kopma\/network split ya\u015fan\u0131rsa? Hangi log i\u015flemi, hangi request i\u00e7erisinde ger\u00e7ekle\u015fti? \u0130\u015fte bu\u00a0gibi\u00a0problemlerde <strong>Correlation ID<\/strong>\u00a0yakla\u015f\u0131m\u0131 imdad\u0131m\u0131za ko\u015fmaktad\u0131r.<\/p>\n<h4>Yakla\u015f\u0131m<\/h4>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-895 lazyload\" data-src=\"\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow.jpg\" alt=\"payment-logging-with-correlation-id-flow\" width=\"1203\" height=\"654\" data-srcset=\"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow.jpg 1203w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-300x163.jpg 300w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1024x557.jpg 1024w\" data-sizes=\"(max-width: 1203px) 100vw, 1203px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1203px; --smush-placeholder-aspect-ratio: 1203\/654;\" \/><\/a><\/p>\n<p>Service&#8217;ler aras\u0131nda her bir request i\u00e7in\u00a0unique identifier g\u00f6revini g\u00f6recek olan bir Correlation ID gezdirilir. Bu sayede hangi request hangi ko\u015fullarda ve nas\u0131l hata al\u0131nd\u0131\u011f\u0131n\u0131n log&#8217;lar\u0131n\u0131 takip edebilmek, olduk\u00e7a kolayla\u015facakt\u0131r.<\/p>\n<p>Distributed yakla\u015f\u0131mlar\u0131n d\u0131\u015f\u0131nda baz\u0131 durumlarda ise\u00a0uygulamalar\u0131m\u0131zda ki\u00a0bottleneck&#8217;leri ortaya koyabilmek i\u00e7in farkl\u0131 senaryolarda test case&#8217;leri ve log i\u015flemleri ger\u00e7ekle\u015ftiririz.<\/p>\n<p>\u00d6rne\u011fin X request&#8217;i, ilgili result set&#8217;i olu\u015fturabilmek i\u00e7in hangi business process&#8217;lerden\/gateway&#8217;lerden ge\u00e7iyor? Hangi parametreler ile ilerliyor? Nerede ne kadar vakit harc\u0131yor?<\/p>\n<p>Bunlar gibi sorular\u0131 cevaplayabilmek i\u00e7in,\u00a0log&#8217;lama\u00a0i\u015flemini ger\u00e7ekle\u015ftirirken\u00a0Correlation ID\u00a0\u00e7\u00f6z\u00fcm\u00fc ile ilerleyebiliriz. Bu sayede istedi\u011fimiz contextual bilgileri log&#8217;larken, Correlation ID ile de\u00a0log&#8217;lamadaki\u00a0traceability&#8217;i artt\u0131rarak, bottleneck&#8217;leri h\u0131zl\u0131 bir \u015fekilde ortaya koyabiliriz.<\/p>\n<pre class=\"lang:c# decode:true\">[Info:Entering] CorrelationID:12345 10\/16\/2016 10:05:45.125 FooNamespace.FooClass.FooMethod&lt;T&gt;, \"Parameter_1\", \"Parameter_2\"\r\n[Info:Executing] CorrelationID:12345 10\/16\/2016 10:05:58.95 FooNamespace.FooClass.FooMethod&lt;T&gt;, \"Parameter_1\", \"Parameter_2\"\r\n[Info:Leaving] CorrelationID:12345 10\/16\/2016 10:06:20.45 FooNamespace.FooClass.FooMethod&lt;T&gt;, \"Parameter_1\", \"Parameter_2\"<\/pre>\n<h4>Loglama<\/h4>\n<p>Ger\u00e7ekle\u015ftirece\u011fimiz \u00f6rnekte log&#8217;lama i\u00e7in <em>NLog<\/em> k\u00fct\u00fcphanesini kullanaca\u011f\u0131m. Loglama yaparken herhangi bir aspect k\u00fct\u00fcphanesi kullanmayaca\u011f\u0131m. Sizler dilerseniz lisansl\u0131 olarak <em>PostSharp<\/em> veya open-source olarak\u00a0<em>Fody<\/em> gibi k\u00fct\u00fcphaneler\u00a0arac\u0131l\u0131\u011f\u0131 ile intercept i\u015flemlerini ger\u00e7ekle\u015ftirerek log&#8217;lamalar\u0131 yapabilirsiniz.<\/p>\n<p>&#8220;<em>LogTraceWithCorrelationId<\/em>&#8221; isminde yeni bir console application olu\u015ftural\u0131m. \u0130\u00e7erisine a\u015fa\u011f\u0131daki resimde oldu\u011fu gibi <em>NuGet<\/em>\u00a0\u00fczerinden &#8220;<em>NLog<\/em>&#8221; ve &#8220;<em>NLog.Config<\/em>&#8221; k\u00fct\u00fcphanelerini kural\u0131m.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/NLog.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-902 lazyload\" data-src=\"\/wp-content\/uploads\/2016\/10\/NLog.jpg\" alt=\"nlog\" width=\"715\" height=\"268\" data-srcset=\"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/NLog.jpg 715w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/NLog-300x112.jpg 300w\" data-sizes=\"(max-width: 715px) 100vw, 715px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 715px; --smush-placeholder-aspect-ratio: 715\/268;\" \/><\/a><\/p>\n<p>K\u00fct\u00fcphanelerin kurulumu ard\u0131ndan \u00f6ncelikle &#8220;<em>NLog.config<\/em>&#8221; dosyas\u0131n\u0131 a\u015fa\u011f\u0131daki gibi d\u00fczenleyelim.<\/p>\n<pre class=\"lang:default decode:true \">&lt;nlog xmlns=\"http:\/\/www.nlog-project.org\/schemas\/NLog.xsd\"\r\n      xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n      throwExceptions=\"true\"\r\n      internalLogLevel=\"Trace\"\r\n      internalLogFile=\"..\\..\\..\\Logs\\nlog-app.log\"&gt;\r\n  &lt;targets&gt;\r\n    &lt;!-- database --&gt;\r\n    &lt;target name=\"database\" xsi:type=\"Database\" keepConnection=\"true\" useTransactions=\"true\"\r\n             dbProvider=\"System.Data.SqlClient\"\r\n             connectionString=\"data source=.;initial catalog=TestDb;integrated security=true;\"\r\n              commandText=\"INSERT INTO Logs(EventDateTime, EventLevel, CorrelationId, MachineName, EventMessage, ErrorSource, ErrorClass, ErrorMethod, ErrorMessage, InnerErrorMessage) VALUES (@EventDateTime, @EventLevel, @CorrelationId, @MachineName, @EventMessage, @ErrorSource, @ErrorClass, @ErrorMethod, @ErrorMessage, @InnerErrorMessage)\"&gt;\r\n\r\n      &lt;!-- parameters for the command --&gt;\r\n      &lt;parameter name=\"@EventDateTime\" layout=\"${date:s}\" \/&gt;\r\n      &lt;parameter name=\"@EventLevel\" layout=\"${level}\" \/&gt;\r\n      &lt;parameter name=\"@CorrelationId\" layout=\"${activityid}\"\/&gt;\r\n      &lt;parameter name=\"@MachineName\" layout=\"${machinename}\" \/&gt;\r\n      &lt;parameter name=\"@EventMessage\" layout=\"${message}\" \/&gt;\r\n      &lt;parameter name=\"@ErrorSource\" layout=\"${event-context:item=error-source}\" \/&gt;\r\n      &lt;parameter name=\"@ErrorClass\" layout=\"${event-context:item=error-class}\" \/&gt;\r\n      &lt;parameter name=\"@ErrorMethod\" layout=\"${event-context:item=error-method}\" \/&gt;\r\n      &lt;parameter name=\"@ErrorMessage\" layout=\"${event-context:item=error-message}\" \/&gt;\r\n      &lt;parameter name=\"@InnerErrorMessage\" layout=\"${event-context:item=inner-error-message}\" \/&gt;\r\n    &lt;\/target&gt;\r\n  &lt;\/targets&gt;\r\n  &lt;rules&gt;\r\n    &lt;!-- logging rules here --&gt;\r\n    &lt;logger name=\"*\" minlevel=\"Debug\" writeTo=\"database\" \/&gt;\r\n  &lt;\/rules&gt;\r\n&lt;\/nlog&gt;<\/pre>\n<p>Bu config dosyas\u0131 ile log&#8217;lar\u0131n\u00a0database&#8217;e kaydedilmesi gerekti\u011fini, parameter&#8217;lar ile de &#8220;<em>commandText<\/em>&#8221; \u00fczerindeki parametreleri set ediyoruz. &#8220;<em>rules<\/em>&#8221; k\u0131sm\u0131nda ise &#8220;<em>minlevel<\/em>&#8221; parametresi ile &#8220;<em>debug<\/em>&#8221; seviyesinde log&#8217;lanmas\u0131n\u0131 ve target olarak da &#8220;<em>database<\/em>&#8221; target&#8217;\u0131n\u0131 kullanmas\u0131n\u0131 s\u00f6yl\u00fcyoruz.<\/p>\n<p><em>NLog<\/em> ba\u015fl\u0131ca a\u015fa\u011f\u0131daki log level&#8217;lar\u0131n\u0131 desteklemektedir:<\/p>\n<ul>\n<li><strong>Trace<\/strong>: bu level genelde development s\u0131ras\u0131nda detayl\u0131 olarak hight-volume bilgilere eri\u015febilmek i\u00e7in kullan\u0131lmaktad\u0131r.<\/li>\n<li><strong>Debug<\/strong>: bu level&#8217;da production ortam\u0131nda kullan\u0131lmaz ve\u00a0trace level&#8217;\u0131ndan daha az bilgi i\u00e7ermektedir.<\/li>\n<li><strong>Info<\/strong>: genelde information bilgileri i\u00e7in kullan\u0131l\u0131r ve production ortamlar\u0131nda da kullan\u0131labilinir.<\/li>\n<\/ul>\n<p>Bize \u00f6rne\u011fimizde debug level&#8217;\u0131 yeterli olacakt\u0131r.<\/p>\n<p>Config dosyas\u0131n\u0131n ayarlanmas\u0131 ard\u0131ndan yukar\u0131daki parametrelere denk gelecek olan <em>SQL<\/em> tablosunu da a\u015fa\u011f\u0131daki script ile olu\u015ftural\u0131m.<\/p>\n<pre class=\"lang:tsql decode:true\">CREATE TABLE [dbo].[Logs](\r\n\t[Id] [int] IDENTITY(1,1) NOT NULL,\r\n\t[EventDateTime] [datetime] NOT NULL,\r\n\t[EventLevel] [nvarchar](100) NOT NULL,\r\n\t[CorrelationId] [uniqueidentifier] NOT NULL,\r\n\t[MachineName] [nvarchar](100) NOT NULL,\r\n\t[EventMessage] [nvarchar](max) NOT NULL,\r\n\t[ErrorSource] [nvarchar](100) NULL,\r\n\t[ErrorClass] [nvarchar](500) NULL,\r\n\t[ErrorMethod] [nvarchar](max) NULL,\r\n\t[ErrorMessage] [nvarchar](max) NULL,\r\n\t[InnerErrorMessage] [nvarchar](max) NULL,\r\n CONSTRAINT [PK_Logs] PRIMARY KEY CLUSTERED \r\n(\r\n\t[Id] ASC\r\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, \r\n ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\r\n) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]<\/pre>\n<p>Tablo field&#8217;lar\u0131na\u00a0dikkat ettiyseniz &#8220;<em>CorrelationId<\/em>&#8221; field&#8217;\u0131 d\u0131\u015f\u0131ndakiler, <em>NLog<\/em>&#8216;un sahip oldu\u011fu default field&#8217;lard\u0131r. Bu b\u00f6l\u00fcmde ise\u00a0&#8220;<em>CorrelationId<\/em>&#8221; field&#8217;\u0131n\u0131 nas\u0131l kullanabilece\u011fimize\u00a0bakaca\u011f\u0131z.<\/p>\n<p><em>NLog<\/em>&#8216;un 4.1 versiyonundan sonra &#8220;${activityid}&#8221; parametresi ile, log mesajlar\u0131n\u0131 trace edebilmek i\u00e7in correlation id deste\u011fi getirilmi\u015ftir. Bundan \u00f6nceki versiyonlar\u0131nda ise bu tarz bir i\u015flemler i\u00e7in custom olarak bir layout renderer yazmak gerekiyordu.<\/p>\n<blockquote><p><strong>Not<\/strong>: <em>NLog<\/em>&#8216;un ${activityid} parametresi correlation id&#8217;yi &#8220;<em>System.Diagnostics<\/em>&#8221; namespace&#8217;i alt\u0131nda bulunan, &#8220;<em>Trace.CorrelationManager.ActivityId<\/em>&#8221; property&#8217;sinden okumaktad\u0131r.<\/p><\/blockquote>\n<p>Log k\u00fct\u00fcphanesi haz\u0131r oldu\u011funa g\u00f6re &#8220;<em>Program.cs<\/em>&#8221; i a\u00e7al\u0131m ve a\u015fa\u011f\u0131daki gibi kodlayal\u0131m.<\/p>\n<pre class=\"lang:c# decode:true\">using System;\r\nusing NLog;\r\n\r\nnamespace LogTraceWithCorrelationId\r\n{\r\n    class Program\r\n    {\r\n        private static Logger _logger = LogManager.GetCurrentClassLogger();\r\n\r\n        static void Main(string[] args)\r\n        {\r\n            \/\/Per request\r\n            System.Diagnostics.Trace.CorrelationManager.ActivityId = Guid.NewGuid();\r\n\r\n            DoWork();\r\n        }\r\n\r\n        private static void DoWork()\r\n        {\r\n            \/\/...\r\n\r\n            _logger.Debug(\"DoWork method'u \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131.\");\r\n\r\n            DoOtherWork();\r\n        }\r\n\r\n        private static void DoOtherWork()\r\n        {\r\n            \/\/...\r\n\r\n            _logger.Debug(\"DoOtherWork method'u \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131.\");\r\n        }\r\n    }\r\n}<\/pre>\n<p>Dikkat edersek i\u00e7 i\u00e7e\u00a0sequentially olarak ilerleyen 2 adet method bulunmakta.<\/p>\n<p>&#8220;<em>Main<\/em>&#8221; method&#8217;u i\u00e7erisinde &#8220;<em>System.Diagnostics.Trace.CorrelationManager.ActivityId<\/em>&#8221; property&#8217;sine yeni bir guid set ediyoruz. Ard\u0131ndan ilk method olan &#8220;<em>DoWork<\/em>&#8221; method&#8217;unu call ediyoruz. Method&#8217;lar i\u00e7erisinde ise &#8220;<em>LogManager.GetCurrentClassLogger<\/em>&#8221; method&#8217;u ile elde etmi\u015f oldu\u011fumuz <em>NLog<\/em> instance&#8217;\u0131 \u00fczerinden, &#8220;<em>Debug<\/em>&#8221; method&#8217;unu kullanarak bir log mesaj\u0131 at\u0131yoruz.<\/p>\n<p><em>NLog<\/em> bu i\u015flemlerin ard\u0131ndan bu process bitene kadar set etmi\u015f oldu\u011fumuz\u00a0&#8220;<em>ActivityId<\/em>&#8221; parametresini,\u00a0otomatik olarak log&#8217;lar aras\u0131nda ta\u015f\u0131yacakt\u0131r. Bu sayede herhangi bir process\/request i\u00e7in t\u00fcm ak\u0131\u015f\u0131 trace edebilmek kolay bir hale gelecektir.<\/p>\n<p>Yukar\u0131daki console uygulamas\u0131n\u0131 \u00e7al\u0131\u015ft\u0131ral\u0131m ve \u00e7\u0131kt\u0131s\u0131na <em>SQL Server Management Studio<\/em> \u00fczerinden bir bakal\u0131m.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/logs.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-904 lazyload\" data-src=\"\/wp-content\/uploads\/2016\/10\/logs.jpg\" alt=\"logs\" width=\"761\" height=\"89\" data-srcset=\"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/logs.jpg 761w, https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/logs-300x35.jpg 300w\" data-sizes=\"(max-width: 761px) 100vw, 761px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 761px; --smush-placeholder-aspect-ratio: 761\/89;\" \/><\/a><\/p>\n<p>G\u00f6rd\u00fc\u011f\u00fcm\u00fcz gibi atm\u0131\u015f oldu\u011fumuz 2 adet &#8220;<em>Debug<\/em>&#8221; log&#8217;unu, CorrelationId&#8217;leri ile birlikte <em>SQL<\/em> \u00fczerine insert etmi\u015f durumdad\u0131r.<\/p>\n<p>Burada log&#8217;lamak istedi\u011finiz parametreleri, ilgili business value&#8217;lar\u0131n\u0131za g\u00f6re sizler belirleyebilirsiniz.<\/p>\n<p><em>Main<\/em> method&#8217;unda set etmi\u015f oldu\u011fumuz &#8220;<em>ActivityId<\/em>&#8221; parametresini, web\u00a0ortam\u0131nda ise handler&#8217;lar arac\u0131l\u0131\u011f\u0131 ile &#8220;<em>BeginRequest<\/em>&#8221; event&#8217;lar\u0131nda request header&#8217;\u0131na set edebilirsiniz.<\/p>\n<p>Her ne kadar basit bir konu gibi g\u00f6r\u00fcnse de, bir\u00e7ok case kar\u015f\u0131s\u0131nda olduk\u00e7a fayda sa\u011flamaktad\u0131r\/sa\u011flayacakt\u0131r.<\/p>\n<p>Bu makalede sizlere Correlation ID kullan\u0131m\u0131n\u0131n, \u00f6zellikle distributed ortamlarda \u00f6nemini anlatabilmeye\/aktarabilmeye \u00e7al\u0131\u015ft\u0131m. Sizlerde i\u00e7erisinde bulundu\u011funuz ortamlarda, farkl\u0131 k\u00fct\u00fcphaneler arac\u0131l\u0131\u011f\u0131 ile bu i\u015flemi ger\u00e7ekle\u015ftirebilirsiniz.<\/p>\n<p>Umar\u0131m faydal\u0131 bir yaz\u0131 olmu\u015ftur. \u00d6rnek uygulamaya a\u015fa\u011f\u0131dan ula\u015fabilirsiniz.<\/p>\n<p>Takipte kal\u0131n.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2016\/10\/LogTraceWithCorrelationId.rar\">logtracewithcorrelationid<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merhaba arkada\u015flar. Bu makale konusunda\u00a0sizlerle uygulamalar\u0131m\u0131zda Correlation ID arac\u0131l\u0131\u011f\u0131 ile\u00a0consistent bir \u015fekilde nas\u0131l log&#8217;lama i\u015flemlerini ger\u00e7ekle\u015ftirebiliriz\u00a0konusunu ele almaya \u00e7al\u0131\u015faca\u011f\u0131m. \u00c7o\u011fu zaman geli\u015ftirmekte oldu\u011fumuz uygulamalarda, arkaplanda neyin olup bitti\u011fini anlayabilmek i\u00e7in genelde \u00e7e\u015fitli log&#8217;lama i\u015flemlerini ger\u00e7ekle\u015ftiririz. \u00d6zellikle b\u00fcy\u00fcmekte ve\u00a0b\u00fcy\u00fck \u00e7apta olan projelerde, monolithic\u00a0architecture&#8217;lar\u0131n yerine\u00a0distributed architecture&#8217;lar\u0131n tercih&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/gokhan-gokalp.com\/tr\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/\">Devam\u0131n\u0131 okuyun<span class=\"screen-reader-text\">Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":2470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[315,307,309,308,305,312,311,314,306,313,310],"class_list":["post-887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","tag-c-ile-loglama","tag-c-nlog-kullanimi","tag-correlation-id","tag-correlation-id-nedir","tag-nlog","tag-nlog-activity-id","tag-nlog-correlation-id","tag-nlog-fody","tag-nlog-kullanimi","tag-nlog-postsharp","tag-tenant-id","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"tr","enabled_languages":["en","tr"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"tr":{"title":false,"content":false,"excerpt":false}}},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#039;i Sa\u011flamak - G\u00f6khan G\u00f6kalp<\/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:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#039;i Sa\u011flamak - G\u00f6khan G\u00f6kalp\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/\" \/>\n<meta property=\"og:site_name\" content=\"G\u00f6khan G\u00f6kalp\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-16T12:34:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-01-10T08:22:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1203\" \/>\n\t<meta property=\"og:image:height\" content=\"654\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"G\u00f6khan G\u00f6kalp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"G\u00f6khan G\u00f6kalp\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/\"},\"author\":{\"name\":\"G\u00f6khan G\u00f6kalp\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#\\\/schema\\\/person\\\/7e2a7fa98babd22a5fdae563c4b8cdbe\"},\"headline\":\"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak\",\"datePublished\":\"2016-10-16T12:34:46+00:00\",\"dateModified\":\"2019-01-10T08:22:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/\"},\"wordCount\":993,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#\\\/schema\\\/person\\\/7e2a7fa98babd22a5fdae563c4b8cdbe\"},\"image\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/uploads\\\/2016\\\/10\\\/payment-logging-with-correlation-id-flow-1.jpg\",\"keywords\":[\"C# ile Loglama\",\"C# NLog kullan\u0131m\u0131\",\"Correlation Id\",\"Correlation Id Nedir\",\"NLog\",\"NLog Activity Id\",\"NLog Correlation Id\",\"NLog Fody\",\"NLog kullan\u0131m\u0131\",\"NLog PostSharp\",\"Tenant Id\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/\",\"url\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/\",\"name\":\"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability'i Sa\u011flamak - G\u00f6khan G\u00f6kalp\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/uploads\\\/2016\\\/10\\\/payment-logging-with-correlation-id-flow-1.jpg\",\"datePublished\":\"2016-10-16T12:34:46+00:00\",\"dateModified\":\"2019-01-10T08:22:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#primaryimage\",\"url\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/uploads\\\/2016\\\/10\\\/payment-logging-with-correlation-id-flow-1.jpg\",\"contentUrl\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/uploads\\\/2016\\\/10\\\/payment-logging-with-correlation-id-flow-1.jpg\",\"width\":1203,\"height\":654},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gokhan-gokalp.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#website\",\"url\":\"https:\\\/\\\/gokhan-gokalp.com\\\/\",\"name\":\"G\u00f6khan G\u00f6kalp\",\"description\":\"C# &amp; Python lover\",\"publisher\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#\\\/schema\\\/person\\\/7e2a7fa98babd22a5fdae563c4b8cdbe\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gokhan-gokalp.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/#\\\/schema\\\/person\\\/7e2a7fa98babd22a5fdae563c4b8cdbe\",\"name\":\"G\u00f6khan G\u00f6kalp\",\"pronouns\":\"he\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/litespeed\\\/avatar\\\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659\",\"url\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/litespeed\\\/avatar\\\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659\",\"contentUrl\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/litespeed\\\/avatar\\\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659\",\"caption\":\"G\u00f6khan G\u00f6kalp\"},\"logo\":{\"@id\":\"https:\\\/\\\/gokhan-gokalp.com\\\/wp-content\\\/litespeed\\\/avatar\\\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659\"},\"sameAs\":[\"https:\\\/\\\/gokhan-gokalp.com\"],\"url\":\"https:\\\/\\\/gokhan-gokalp.com\\\/tr\\\/author\\\/gok-gokalp\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability'i Sa\u011flamak - G\u00f6khan G\u00f6kalp","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:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/","og_locale":"tr_TR","og_type":"article","og_title":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability'i Sa\u011flamak - G\u00f6khan G\u00f6kalp","og_url":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/","og_site_name":"G\u00f6khan G\u00f6kalp","article_published_time":"2016-10-16T12:34:46+00:00","article_modified_time":"2019-01-10T08:22:48+00:00","og_image":[{"width":1203,"height":654,"url":"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg","type":"image\/jpeg"}],"author":"G\u00f6khan G\u00f6kalp","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"G\u00f6khan G\u00f6kalp","Tahmini okuma s\u00fcresi":"7 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#article","isPartOf":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/"},"author":{"name":"G\u00f6khan G\u00f6kalp","@id":"https:\/\/gokhan-gokalp.com\/#\/schema\/person\/7e2a7fa98babd22a5fdae563c4b8cdbe"},"headline":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak","datePublished":"2016-10-16T12:34:46+00:00","dateModified":"2019-01-10T08:22:48+00:00","mainEntityOfPage":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/"},"wordCount":993,"commentCount":6,"publisher":{"@id":"https:\/\/gokhan-gokalp.com\/#\/schema\/person\/7e2a7fa98babd22a5fdae563c4b8cdbe"},"image":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#primaryimage"},"thumbnailUrl":"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg","keywords":["C# ile Loglama","C# NLog kullan\u0131m\u0131","Correlation Id","Correlation Id Nedir","NLog","NLog Activity Id","NLog Correlation Id","NLog Fody","NLog kullan\u0131m\u0131","NLog PostSharp","Tenant Id"],"articleSection":[".NET"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/","url":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/","name":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability'i Sa\u011flamak - G\u00f6khan G\u00f6kalp","isPartOf":{"@id":"https:\/\/gokhan-gokalp.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#primaryimage"},"image":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#primaryimage"},"thumbnailUrl":"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg","datePublished":"2016-10-16T12:34:46+00:00","dateModified":"2019-01-10T08:22:48+00:00","breadcrumb":{"@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/"]}]},{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#primaryimage","url":"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg","contentUrl":"https:\/\/gokhan-gokalp.com\/wp-content\/uploads\/2016\/10\/payment-logging-with-correlation-id-flow-1.jpg","width":1203,"height":654},{"@type":"BreadcrumbList","@id":"https:\/\/gokhan-gokalp.com\/loglama-yapilarinda-correlation-id-ile-traceabilityi-saglamak\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gokhan-gokalp.com\/"},{"@type":"ListItem","position":2,"name":"Loglama Yap\u0131lar\u0131nda Correlation ID ile Traceability&#8217;i Sa\u011flamak"}]},{"@type":"WebSite","@id":"https:\/\/gokhan-gokalp.com\/#website","url":"https:\/\/gokhan-gokalp.com\/","name":"G\u00f6khan G\u00f6kalp","description":"C# &amp; Python lover","publisher":{"@id":"https:\/\/gokhan-gokalp.com\/#\/schema\/person\/7e2a7fa98babd22a5fdae563c4b8cdbe"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gokhan-gokalp.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/gokhan-gokalp.com\/#\/schema\/person\/7e2a7fa98babd22a5fdae563c4b8cdbe","name":"G\u00f6khan G\u00f6kalp","pronouns":"he","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/gokhan-gokalp.com\/wp-content\/litespeed\/avatar\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659","url":"https:\/\/gokhan-gokalp.com\/wp-content\/litespeed\/avatar\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659","contentUrl":"https:\/\/gokhan-gokalp.com\/wp-content\/litespeed\/avatar\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659","caption":"G\u00f6khan G\u00f6kalp"},"logo":{"@id":"https:\/\/gokhan-gokalp.com\/wp-content\/litespeed\/avatar\/e645f66b6264ced10d7b6d8b1f85509b.jpg?ver=1776170659"},"sameAs":["https:\/\/gokhan-gokalp.com"],"url":"https:\/\/gokhan-gokalp.com\/tr\/author\/gok-gokalp\/"}]}},"_links":{"self":[{"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/posts\/887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/comments?post=887"}],"version-history":[{"count":15,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/posts\/887\/revisions"}],"predecessor-version":[{"id":2472,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/posts\/887\/revisions\/2472"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/media\/2470"}],"wp:attachment":[{"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/media?parent=887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/categories?post=887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gokhan-gokalp.com\/tr\/wp-json\/wp\/v2\/tags?post=887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}