Пример #1
0
        protected override void Write(LogEventInfo logEvent)
        {
            if (logEvent.Level < LogLevel.Error || logEvent.Exception == null)
            {
                return;
            }

            var container = _client.GetContainerReference(BlobHelper.BuildContainerName(logEvent));

            container.CreateIfNotExists();

            var blobName = BlobHelper.BuildNameFromLogEvent(logEvent);

            var blob = container.GetBlockBlobReference(blobName);

            var index = 0;

            while (blob.Exists())
            {
                index++;
                blob = container.GetBlockBlobReference(blobName + "_" + index);
            }

            blob.Properties.ContentType = "text/plain";

            var logMessage = Layout.Render(logEvent);

            blob.UploadText(logMessage);

            Debug.WriteLine("Writing to blob storage: " + blob.Uri);
        }