/// <summary>
        /// Construct a sink that saves logs to the specified storage account.
        /// </summary>
        /// <param name="storageAccount">The Cloud Storage Account to use to insert the log entries to.</param>
        /// <param name="textFormatter"></param>
        /// <param name="batchSizeLimit"></param>
        /// <param name="period"></param>
        /// <param name="storageContainerName">Container where the log entries will be written to. Note: Optional, setting this may impact performance</param>
        /// <param name="storageFileName">File name that log entries will be written to. Note: Optional, setting this may impact performance</param>
        /// <param name="bypassBlobCreationValidation">Bypass the exception in case the blob creation fails.</param>
        /// <param name="cloudBlobProvider">Cloud blob provider to get current log blob.</param>
        /// <param name="appendBlobBlockPreparer"></param>
        /// <param name="appendBlobBlockWriter"></param>
        public AzureBatchingBlobStorageSink(
            CloudStorageAccount storageAccount,
            ITextFormatter textFormatter,
            int batchSizeLimit,
            TimeSpan period,
            string storageContainerName                      = null,
            string storageFileName                           = null,
            bool bypassBlobCreationValidation                = false,
            ICloudBlobProvider cloudBlobProvider             = null,
            IAppendBlobBlockPreparer appendBlobBlockPreparer = null,
            IAppendBlobBlockWriter appendBlobBlockWriter     = null)
            : base(batchSizeLimit, period)
        {
            this.textFormatter = textFormatter;

            if (string.IsNullOrEmpty(storageContainerName))
            {
                storageContainerName = "logs";
            }

            if (string.IsNullOrEmpty(storageFileName))
            {
                storageFileName = "log.txt";
            }

            this.storageAccount               = storageAccount;
            this.storageContainerName         = storageContainerName;
            this.blobNameFactory              = new BlobNameFactory(storageFileName);
            this.bypassBlobCreationValidation = bypassBlobCreationValidation;
            this.cloudBlobProvider            = cloudBlobProvider ?? new DefaultCloudBlobProvider();
            this.appendBlobBlockPreparer      = appendBlobBlockPreparer ?? new DefaultAppendBlobBlockPreparer();
            this.appendBlobBlockWriter        = appendBlobBlockWriter ?? new DefaultAppendBlobBlockWriter();
        }
        /// <summary>
        /// Construct a sink that saves logs to the specified storage account.
        /// </summary>
        /// <param name="cloudBlobClient">The Cloud Storage Client to use to insert the log entries to.</param>
        /// <param name="textFormatter"></param>
        /// <param name="storageContainerName">Container where the log entries will be written to.</param>
        /// <param name="storageFileName">File name that log entries will be written to.</param>
        /// <param name="bypassContainerCreationValidation">Bypass the exception in case the container creation fails.</param>
        /// <param name="cloudBlobProvider">Cloud blob provider to get current log blob.</param>
        /// <param name="appendBlobBlockPreparer"></param>
        /// <param name="appendBlobBlockWriter"></param>
        /// <param name="blobSizeLimitBytes">The maximum file size to allow before a new one is rolled, expressed in bytes.</param>
        /// <param name="retainedBlobCountLimit">The number of latest blobs to be retained in the container always. Deletes older blobs when this limit is crossed.</param>
        public AzureBlobStorageSink(
            CloudBlobClient cloudBlobClient,
            ITextFormatter textFormatter,
            string storageContainerName                      = null,
            string storageFileName                           = null,
            bool bypassContainerCreationValidation           = false,
            ICloudBlobProvider cloudBlobProvider             = null,
            IAppendBlobBlockPreparer appendBlobBlockPreparer = null,
            IAppendBlobBlockWriter appendBlobBlockWriter     = null,
            long?blobSizeLimitBytes                          = null,
            int?retainedBlobCountLimit                       = null)
        {
            this.textFormatter = textFormatter;

            if (string.IsNullOrEmpty(storageContainerName))
            {
                storageContainerName = "logs";
            }

            if (string.IsNullOrEmpty(storageFileName))
            {
                storageFileName = "log.txt";
            }

            this.cloudBlobClient      = cloudBlobClient;
            this.storageContainerName = storageContainerName;
            blobNameFactory           = new BlobNameFactory(storageFileName);
            this.bypassContainerCreationValidation = bypassContainerCreationValidation;
            this.cloudBlobProvider       = cloudBlobProvider ?? new DefaultCloudBlobProvider();
            this.appendBlobBlockPreparer = appendBlobBlockPreparer ?? new DefaultAppendBlobBlockPreparer();
            this.appendBlobBlockWriter   = appendBlobBlockWriter ?? new DefaultAppendBlobBlockWriter();
            this.blobSizeLimitBytes      = blobSizeLimitBytes;
            this.retainedBlobCountLimit  = retainedBlobCountLimit;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Construct a sink that saves logs to the specified storage account.
        /// </summary>
        /// <param name="storageAccount">The Cloud Storage Account to use to insert the log entries to.</param>
        /// <param name="textFormatter"></param>
        /// <param name="storageFolderName">Folder name that log entries will be written to.</param>
        /// <param name="storageFileName">File name that log entries will be written to.</param>
        /// <param name="bypassFolderCreationValidation">Bypass the exception in case the folder creation fails.</param>
        /// <param name="cloudBlobProvider">Cloud blob provider to get current log blob.</param>
        /// <param name="appendBlobBlockPreparer"></param>
        /// <param name="appendBlobBlockWriter"></param>
        public AzureBlobStorageSink(
            CloudStorageAccount storageAccount,
            ITextFormatter textFormatter,
            string storageFolderName                         = null,
            string storageFileName                           = null,
            bool bypassFolderCreationValidation              = false,
            ICloudBlobProvider cloudBlobProvider             = null,
            IAppendBlobBlockPreparer appendBlobBlockPreparer = null,
            IAppendBlobBlockWriter appendBlobBlockWriter     = null)
        {
            this.textFormatter = textFormatter;

            if (string.IsNullOrEmpty(storageFolderName))
            {
                storageFolderName = "logs";
            }

            if (string.IsNullOrEmpty(storageFileName))
            {
                storageFileName = "log.txt";
            }

            this.storageAccount    = storageAccount;
            this.storageFolderName = storageFolderName;
            blobNameFactory        = new BlobNameFactory(storageFileName);
            this.bypassFolderCreationValidation = bypassFolderCreationValidation;
            this.cloudBlobProvider       = cloudBlobProvider ?? new DefaultCloudBlobProvider();
            this.appendBlobBlockPreparer = appendBlobBlockPreparer ?? new DefaultAppendBlobBlockPreparer();
            this.appendBlobBlockWriter   = appendBlobBlockWriter ?? new DefaultAppendBlobBlockWriter();
        }