Reputation: 135
Trying to insert logs into Azure table storage, while using the extension of NLog.Extensions.AzureTableStorage in Nlog.config file , i am getting error under target type for azure table storage.
Error : - This is invalid xsi:type http://www.nlog-project.org/schemas/NLog.xsd:AzureTableStorage
FYI - I am using latest version Nlog latest version 4.4.11 & i added extension of Nlog.extensions.azuretablestorage(Nuget version 1.1.4)
Update for config file:
<extensions>
<add assembly="NLog.Extensions.AzureTableStorage"/>
</extensions>
<!-- set up a an azure storage table target -->
<targets>
<target name="AzureTableStorage" xsi:type="AzureTableStorage" PartitionKey="${date}.${logger}" RowKey="${ticks}.${guid}" ConnectionString="UseDevelopmentStorage=true" tableName="TempAzureTableStorageTargetTestsLogs" />
</targets>
Upvotes: 1
Views: 2937
Reputation: 18465
This is invalid xsi:type http://www.nlog-project.org/schemas/NLog.xsd:AzureTableStorage
I assumed that you have installed NLog.Config that would automatically create the default NLog.config
. Since this package references NLog.Schema which would enable Intellisense(TM) when editing NLog configuration files.
I have checked with this issue, the above message is just for warning, the logging feature would be fine. And you could remove the NLog.Config and NLog.Config packages, then the warning message would go away.
FYI - I am using latest version Nlog latest version 4.4.11 & i added extension of Nlog.extensions.azuretablestorage(Nuget version 1.1.4)
AFAIK, the latest version for NLog Azure Table Storage Target is 1.0.11. Here is my code snippet, you could refer to it:
NLog.config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<extensions>
<add assembly="NLog.Extensions.AzureTableStorage"/>
</extensions>
<targets>
<target xsi:type="AzureTableStorage"
name="NLogAzureTable"
ConnectionStringKey="NLog.Azure.TableStorage.ConnectionString"
TableName="NLogTable"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="NLogAzureTable" />
<logger name="*" minlevel="Info" writeTo="console" />
</rules>
</nlog>
App.config
<appSettings>
<add key="NLog.Azure.TableStorage.ConnectionString" value="{your-storage-account-connectionString}" />
</appSettings>
Usage:
var logger = LogManager.GetLogger(nameof(Program));
logger.Info("hello world!!!");
Result:
For more details about how to configure the NLog Azure Table Storage Target, you could refer to NLog.Extensions.AzureTableStorage. Also, you could refer to NLog for more tutorials.
Upvotes: 0