Click or drag to resize

AzureTableTarget Class

Extends TargetWithContext to write to Azure tables using the existing Inner Drive Technology column format
Inheritance Hierarchy
SystemObject
  Target
    TargetWithLayout
      TargetWithContext
        AsyncTaskTarget
          InnerDrive.LoggingAzureTableTarget

Namespace: InnerDrive.Logging
Assembly: InnerDrive.Logging (in InnerDrive.Logging.dll) Version: 5.0.8475.0
Syntax
C#
[TargetAttribute("AzureTableTarget")]
public class AzureTableTarget : AsyncTaskTarget

The AzureTableTarget type exposes the following members.

Constructors
 NameDescription
Public methodAzureTableTarget Creates a new instance of AzureTableTarget
Public methodAzureTableTarget(IConfiguration) Creates a new instance of AzureTableTarget with configuration data
Public methodAzureTableTarget(ISecretProvider) Creates a new instance of AzureTableTarget with configuration data
Top
Properties
 NameDescription
Public propertyAccountKey Gets or sets the Microsoft Azure connection string
Public propertyAccountName Gets or sets the Microsoft Azure connection string
Public propertyApplicationName Gets or sets the application name to use
Public propertyBaseTableName Gets or sets the table to use; default is time-based
Public propertyBatchSize Gets or sets the number of log events that should be processed in a batch by the lazy writer thread.
(Inherited from AsyncTaskTarget)
Public propertyConfiguration Gets or sets a IConfiguration provider
Public propertyContextProperties Gets the array of custom attributes to be passed into the logevent context
(Inherited from TargetWithContext)
Public propertyExcludeProperties List of property names to exclude when IncludeEventProperties is true
(Inherited from TargetWithContext)
Public propertyForceLockingQueue Gets or sets whether to use the locking queue, instead of a lock-free concurrent queue The locking queue is less concurrent when many logger threads, but reduces memory allocation
(Inherited from AsyncTaskTarget)
Public propertyIncludeCallSite Gets or sets a value indicating whether to include call site (class and method name) in the LogEventInfo
(Inherited from TargetWithContext)
Public propertyIncludeCallSiteStackTrace Gets or sets a value indicating whether to include source info (file name and line number) in the LogEventInfo
(Inherited from TargetWithContext)
Public propertyIncludeEventProperties Gets or sets the option to include all properties from the log events
(Inherited from TargetWithContext)
Public propertyIncludeGdc Gets or sets a value indicating whether to include contents of the GlobalDiagnosticsContext dictionary
(Inherited from TargetWithContext)
Public propertyIncludeMdcObsolete.

(Inherited from TargetWithContext)
Public propertyIncludeMdlcObsolete.

(Inherited from TargetWithContext)
Public propertyIncludeNdcObsolete.

(Inherited from TargetWithContext)
Public propertyIncludeNdlcObsolete.

(Inherited from TargetWithContext)
Public propertyIncludeScopeNested Gets or sets whether to include the contents of the ScopeContext nested-state-stack.
(Inherited from TargetWithContext)
Public propertyIncludeScopeProperties Gets or sets whether to include the contents of the ScopeContext properties-dictionary.
(Inherited from TargetWithContext)
Protected propertyIsInitialized Gets a value indicating whether the target has been initialized.
(Inherited from Target)
Public propertyLayout
(Inherited from TargetWithContext)
Public propertyLayoutWithLockObsolete.
NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using AsyncTargetWrapper or AsyncTaskTarget. But if using custom Layout or LayoutRenderer that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies.
(Inherited from Target)
Protected propertyLoggingConfiguration Gets the logging configuration this target is part of.
(Inherited from Target)
Public propertyName Gets or sets the name of the target.
(Inherited from Target)
Public propertyOptimizeBufferReuseObsolete.
Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
(Inherited from Target)
Public propertyOverflowAction Gets or sets the action to be taken when the lazy writer thread request queue count exceeds the set limit.
(Inherited from AsyncTaskTarget)
Public propertyQueueLimit Gets or sets the limit on the number of requests in the lazy writer thread request queue.
(Inherited from AsyncTaskTarget)
Public propertyRetryCount How many attempts to retry the same Task, before it is aborted
(Inherited from AsyncTaskTarget)
Public propertyRetryDelayMilliseconds How many milliseconds to wait before next retry (will double with each retry)
(Inherited from AsyncTaskTarget)
Public propertySource Gets or sets the subject of the message
Protected propertySyncRoot Gets the object which can be used to synchronize asynchronous operations that must rely on the .
(Inherited from Target)
Public propertyTablesUri Gets or sets the Microsoft Azure connection string
Public propertyTaskDelayMilliseconds How many milliseconds to delay the actual write operation to optimize for batching
(Inherited from AsyncTaskTarget)
Protected propertyTaskScheduler Task Scheduler used for processing async Tasks
(Inherited from AsyncTaskTarget)
Public propertyTaskTimeoutSeconds How many seconds a Task is allowed to run before it is cancelled.
(Inherited from AsyncTaskTarget)
Top
Methods
 NameDescription
Protected methodCaptureContextGdc Takes snapshot of GlobalDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureContextMdcObsolete.
Takes snapshot of MappedDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureContextMdlcObsolete.
Takes snapshot of MappedDiagnosticsLogicalContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureContextNdcObsolete.
Takes snapshot of NestedDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureContextNdlcObsolete.
Takes snapshot of NestedDiagnosticsLogicalContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureScopeContextNested Takes snapshot of nested states from ScopeContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCaptureScopeContextProperties Takes snapshot of ScopeContext dictionary for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodCloseTarget Closes Target by updating CancellationToken
(Inherited from AsyncTaskTarget)
Public methodDispose Closes the target.
(Inherited from Target)
Protected methodDispose(Boolean) Releases any managed resources
(Inherited from AsyncTaskTarget)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodFlush Flush any pending log messages (in case of asynchronous targets).
(Inherited from Target)
Protected methodFlushAsync Schedules notification of when all messages has been written
(Inherited from AsyncTaskTarget)
Protected methodGenerateUniqueItemName Generates a new unique name, when duplicate names are detected
(Inherited from TargetWithContext)
Protected methodGetAllProperties(LogEventInfo) Creates combined dictionary of all configured properties for logEvent
(Inherited from TargetWithContext)
Protected methodGetAllProperties(LogEventInfo, IDictionaryString, Object) Creates combined dictionary of all configured properties for logEvent
(Inherited from TargetWithContext)
Protected methodGetContextMdcObsolete.
Returns the captured snapshot of MappedDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodGetContextMdlcObsolete.
Returns the captured snapshot of MappedDiagnosticsLogicalContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodGetContextNdcObsolete.
Returns the captured snapshot of NestedDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodGetContextNdlcObsolete.
Returns the captured snapshot of NestedDiagnosticsLogicalContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodGetContextProperties(LogEventInfo) Checks if any context properties, and if any returns them as a single dictionary
(Inherited from TargetWithContext)
Protected methodGetContextProperties(LogEventInfo, IDictionaryString, Object) Checks if any context properties, and if any returns them as a single dictionary
(Inherited from TargetWithContext)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Protected methodGetScopeContextNested Returns the captured snapshot of nested states from ScopeContext for the LogEventInfo
(Inherited from TargetWithContext)
Protected methodGetScopeContextProperties Returns the captured snapshot of ScopeContext dictionary for the LogEventInfo
(Inherited from TargetWithContext)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodInitializeTarget
(Inherited from AsyncTaskTarget)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodMergeEventPropertiesObsolete.
Merges (copies) the event context properties from any event info object stored in parameters of the given event info object.
(Inherited from Target)
Public methodPrecalculateVolatileLayouts Calls the Precalculate(LogEventInfo) on each volatile layout used by this target. This method won't prerender if all layouts in this target are thread-agnostic.
(Inherited from Target)
Protected methodRenderLogEvent(Layout, LogEventInfo) Renders the logevent into a string-result using the provided layout
(Inherited from Target)
Protected methodRenderLogEvent``1(LayoutUMP, LogEventInfo, UMP) Renders the logevent into a result-value by using the provided layout
(Inherited from Target)
Protected methodResolveService``1 Resolve from DI ServiceRepository
(Inherited from Target)
Protected methodRetryFailedAsyncTask Handle cleanup after failed write operation
(Inherited from AsyncTaskTarget)
Protected methodSerializeItemValue Take snapshot of a single object value
(Inherited from TargetWithContext)
Protected methodSerializeMdcItemObsolete.
Take snapshot of a single object value from MappedDiagnosticsContext
(Inherited from TargetWithContext)
Protected methodSerializeMdlcItemObsolete.
Take snapshot of a single object value from MappedDiagnosticsLogicalContext
(Inherited from TargetWithContext)
Protected methodSerializeNdcItemObsolete.
Take snapshot of a single object value from NestedDiagnosticsContext
(Inherited from TargetWithContext)
Protected methodSerializeNdlcItemObsolete.
Take snapshot of a single object value from NestedDiagnosticsLogicalContext
(Inherited from TargetWithContext)
Protected methodSerializeScopeContextNestedState Take snapshot of a single object value from ScopeContext nested states
(Inherited from TargetWithContext)
Protected methodSerializeScopeContextProperty Take snapshot of a single object value from ScopeContext dictionary
(Inherited from TargetWithContext)
Protected methodShouldIncludeProperties Check if logevent has properties (or context properties)
(Inherited from TargetWithContext)
Public methodToString
(Inherited from Target)
Protected methodWrite(AsyncLogEventInfo)
(Inherited from AsyncTaskTarget)
Protected methodWrite(IListAsyncLogEventInfo) Block for override. Instead override WriteAsyncTask(IListLogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
Protected methodWrite(LogEventInfo) Block for override. Instead override WriteAsyncTask(LogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
Public methodWriteAsyncLogEvent Writes the log to the target.
(Inherited from Target)
Public methodWriteAsyncLogEvents(AsyncLogEventInfo) Writes the array of log events.
(Inherited from Target)
Public methodWriteAsyncLogEvents(IListAsyncLogEventInfo) Writes the array of log events.
(Inherited from Target)
Protected methodWriteAsyncTask(IListLogEventInfo, CancellationToken) Override this to provide async task for writing a batch of logevents.
(Inherited from AsyncTaskTarget)
Protected methodCode exampleWriteAsyncTask(LogEventInfo, CancellationToken) Override this to provide async task for writing a single logevent.
Example
Example of how to override this method, and call custom async method
C#
protected override Task WriteAsyncTask(LogEventInfo logEvent, CancellationToken token)
{
   return CustomWriteAsync(logEvent, token);
}

private async Task CustomWriteAsync(LogEventInfo logEvent, CancellationToken token)
{
    await MyLogMethodAsync(logEvent, token).ConfigureAwait(false);
}

(Overrides AsyncTaskTarget.WriteAsyncTask(LogEventInfo, CancellationToken))
Protected methodWriteAsyncThreadSafe(AsyncLogEventInfo) Write to queue without locking SyncRoot
(Inherited from AsyncTaskTarget)
Protected methodWriteAsyncThreadSafe(IListAsyncLogEventInfo) Block for override. Instead override WriteAsyncTask(IListLogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
Protected methodWriteFailedNotInitialized LogEvent is written to target, but target failed to successfully initialize Enqueue logevent for later processing when target failed to initialize because of unresolved service dependency.
(Inherited from AsyncTaskTarget)
Top
Fields
 NameDescription
Public fieldStatic memberAccountKeyConfigurationSettingName Gets the configuration setting name used to get the Azure storage account key
Public fieldStatic memberAccountNameConfigurationSettingName Gets the configuration setting name used to get the Azure storage account Name
Public fieldStatic memberTablesUriConfigurationSettingName Gets the configuration setting name used to get the Azure storage account Name
Top
Remarks

For best security, use an ISecretProvider (such as the KeyVaultSecretProvider to hold the connection string rather than putting it in configuration files.

If you don't want to use a secret provider, the log target can use the configured IConfiguration provider to obtain the Azure storage connection string. In that case, put the storage connection string in your appSettings.json file in the azureTableTarget:connectionString value:

C#
{
   "azureTableTarget": {
      "connectionString": "super secret connection string"
   }
}

You can also put the connection string in your nLog.config file. Here is the typical nLog.config for this target:

C#
<target xsi:type="AzureTableTarget"
    name = "azureTable"
    applicationName = "Logging.Test"
    baseTableName = "NLogUnitTest"
    connectionString = "super secret connection string"
/>
See Also