Configure xConnect operation logging
Extended xConnect logging includes tracking xConnect commands and the states of operations before and after running the command.
Each operation has a unique batch ID. If an operation fails, it logs the predecessor’s and successor’s operations IDs as well. It is disabled by default.
The xConnect operation log output contains log entries for each command run and a BatchId field. You can find logs of related commands using this BatchId.
The log output contains:
-
A batch ID.
-
The operation name.
-
The operation ID in the batch.
-
The status of the operation run.
-
The operation parameters (for example, contact IDs, identifier fields, and facet information).
-
The operation IDs of predecessors or successors.
Enable xConnect operation logging
To enable xConnect operation logging:
-
Enable the file
\App_Data\Config\Sitecore\Collection\sc.XConnect.Collection.Web.Logging.xml.disabledby renaming the file to\App_Data\Config\Sitecore\Collection\sc.XConnect.Collection.Web.Logging.xml.
xConnect operation log example
The xConnect operation log output contains log entries for each command run. For example:
2021-05-31 21:26:20.695 +03:00 [Verbose] Operation trace
{
"BatchId": "e24aa982-875e-4c2e-a2d8-3ef61dba68a9",
"Command": "Executed",
"Operations": [
{
"BatchId": "e24aa982-875e-4c2e-a2d8-3ef61dba68a9",
"BatchIndex": 0,
"OperationName": "AddContactOperation",
"OperationId": 9,
"Status": "Succeeded",
"OperationType": "Create",
"Info": [
{
"Name": "Parameters",
"Value": [
{
"Name": "Contact id",
"Value": "edb8f791-b618-0000-0000-062578a79910"
},
{
"Name": "Identifiers",
"Value": [
[
{
"Name": "Identifier type",
"Value": "Anonymous"
},
{
"Name": "Source",
"Value": "Tests.contact.source"
},
{
"Name": "Value",
"Value": ".13.M.MergeOperationShouldFailIfOneOfContactsIsNull7a7bd39e7bb94f09905d3184d3df4d2c"
}
],
[
{
"Name": "Identifier type",
"Value": "Anonymous"
},
{
"Name": "Source",
"Value": "Alias"
},
{
"Name": "Value",
"Value": "903aa80a-556f-4b9c-9149-9846dea55718"
}
]
]
}
]
},
{
"Name": "Successors Ids",
"Value": "[ 11 ]"
}
]
},
{
"BatchId": "e24aa982-875e-4c2e-a2d8-3ef61dba68a9",
"BatchIndex": 2,
"OperationName": "SetFacetOperation`1",
"OperationId": 11,
"Status": "Succeeded",
"OperationType": "Update",
"Info": [
{
"Name": "Parameters",
"Value": [
{
"Name": "Entity type",
"Value": "Contact"
},
{
"Name": "Entity id",
"Value": "edb8f791-b618-0000-0000-062578a79910"
},
{
"Name": "Facet key",
"Value": "Personal"
}
]
},
{
"Name": "Predecessors Ids",
"Value": "[ 9 ]"
}
]
}
]
} Change the log level
If the xConnect operation throws an exception while it runs, it logs one of the following types:
-
Only type(only the type of the exception). -
Medium(the type of the exception and a message). -
Full(the full information that the exception instance contains).
By default, the log type level is Medium.
To change the log type level:
-
Open the config file
\App_Data\Config\Sitecore\Collection\sc.XConnect.Collection.Web.Logging.xmland modify the value of theSettings/Sitecore/XConnect/Collection/Services/ExceptionLogFormatter/Options/ExceptionLogLevelnode.RequestResponse<ExceptionLogLevel>Medium</ExceptionLogLevel>
OnlyType level exception example
The following is an example of the log output with a OnlyType log level:
2021-05-31 21:59:14.581 +03:00 [Verbose] Operation trace
{
"BatchId": "3813c258-ae24-4a61-974f-62daa2f83bee",
"Command": "Executed",
"Operations": [
{
"BatchId": "3813c258-ae24-4a61-974f-62daa2f83bee",
"BatchIndex": 0,
"OperationName": "AddContactOperation",
"OperationId": 1,
"Status": "Failed",
"OperationType": "Create",
"Info": [
{
"Name": "Exception",
"Value": "ShardManagementException"
}
]
}
]
}
Medium level exception example:
The following is an example of the log output with a Medium log level:
2021-05-31 21:52:23.726 +03:00 [Verbose] Operation trace
{
"BatchId": "a2e0e099-9be3-428b-98c9-a6c45c334859",
"Command": "Executed",
"Operations": [
{
"BatchId": "a2e0e099-9be3-428b-98c9-a6c45c334859",
"BatchIndex": 0,
"OperationName": "AddContactOperation",
"OperationId": 1,
"Status": "Failed",
"OperationType": "Create",
"Info": [
{
"Name": "Exception",
"Value": {
"Name": "ShardManagementException",
"Message": "Store Error: Login failed for user 'sa'.. The error occurred while attempting to perform the
underlying storage operation during 'Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreException
: Error occurred while performing store operation. See the inner SqlException for details. ---> System
.Data.SqlClient.SqlException: Login failed for user 'sa'.\r\n at System.Data.SqlClient
.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions,
SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean
redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling,
SqlAuthenticationProviderManager sqlAuthProviderManager)\r\n at System.Data.SqlClient.SqlConnectionFactory
.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\r\n at System.Data
.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject,
DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)\r\n at System
.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest
(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32
waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionPool
.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection
(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase
.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory
connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data
.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)\r\n at System.Data.SqlClient
.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\n at System.Data.SqlClient.SqlConnection.Open()\r\n at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.SqlUtils.WithSqlExceptionHandling(Action
operation)\r\n --- End of inner exception stack trace ---\r\n at Microsoft.Azure.SqlDatabase
.ElasticScale.ShardManagement.SqlUtils.WithSqlExceptionHandling(Action operation)\r\n at Microsoft.Azure
.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal.<Do>b__10_0()\r\n at Microsoft.Azure
.SqlDatabase.ElasticScale.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)\r\n at
Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal.Do()' operation on the shard
map manager database. See the inner StoreException for details."
}
}
]
}
]
}
Full level exception example:
The following is an example of the log output with a Full log level:
2021-05-31 22:02:03.197 +03:00 [Verbose] Operation trace
{
"BatchId": "febf5249-fbf6-4d52-a9ef-3941cac2c31b",
"Command": "Executed",
"Operations": [
{
"BatchId": "febf5249-fbf6-4d52-a9ef-3941cac2c31b",
"BatchIndex": 0,
"OperationName": "AddContactOperation",
"OperationId": 1,
"Status": "Failed",
"OperationType": "Create",
"Info": [
{
"Name": "Exception",
"Value": {
"ErrorCategory": 0,
"ErrorCode": 17,
"ClassName": "Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardManagementException",
"Message": "Store Error: Login failed for user 'sa'.. The error occurred while attempting to perform the
underlying storage operation during 'Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreException
: Error occurred while performing store operation. See the inner SqlException for details. ---> System
.Data.SqlClient.SqlException: Login failed for user 'sa'.\r\n at System.Data.SqlClient
.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions,
SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean
redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling,
SqlAuthenticationProviderManager sqlAuthProviderManager)\r\n at System.Data.SqlClient.SqlConnectionFactory
.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\r\n at System.Data
.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject,
DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)\r\n at System
.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest
(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32
waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionPool
.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection
(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase
.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory
connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data
.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)\r\n at System.Data.SqlClient
.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\n at System.Data.SqlClient.SqlConnection.Open()\r\n at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.SqlUtils.WithSqlExceptionHandling(Action
operation)\r\n --- End of inner exception stack trace ---\r\n at Microsoft.Azure.SqlDatabase
.ElasticScale.ShardManagement.SqlUtils.WithSqlExceptionHandling(Action operation)\r\n at Microsoft.Azure
.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal.<Do>b__10_0()\r\n at Microsoft.Azure
.SqlDatabase.ElasticScale.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)\r\n at
Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal.Do()' operation on the shard
map manager database. See the inner StoreException for details.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": "at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal.Do
()\r\n at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardMapManagerFactory
.GetSqlShardMapManager(String connectionString, SqlCredential secureCredential, ShardMapManagerLoadPolicy
loadPolicy, RetryBehavior retryBehavior, EventHandler`1 retryEventHandler, Boolean throwOnFailure)\r\n at
Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardMapManagerFactory.TryGetSqlShardMapManager
(String connectionString, SqlCredential secureCredential, ShardMapManagerLoadPolicy loadPolicy,
RetryBehavior retryBehavior, ShardMapManager& shardMapManager)\r\n at Sitecore.Xdb.Collection.Data
.SqlServer.Configuration.ElasticScaleConnectionManager.InitializeShardMapManager()\r\n at Sitecore.Xdb
.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.get_ShardMapManager()\r\n at
Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.GetRangeShardMap(String
rangeShardMapName)\r\n at Sitecore.Xdb.Collection.Data.SqlServer.Configuration
.ElasticScaleConnectionManager.<>c__DisplayClass33_0.<GetRangeMappings>b__0()\r\n at System.Lazy`1
.CreateValue()\r\n at System.Lazy`1.LazyInitValue()\r\n at Sitecore.Xdb.Collection.Data.SqlServer
.Configuration.MemoryCacheManager.AddOrGetExistingFromCache[T](String key, Func`1 valueFactory)\r\n at
Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.MapRecordsToShards[T]
(String rangeShardMapName, IReadOnlyCollection`1 records, Func`2 getShardKey)\r\n at Sitecore.Xdb
.Collection.Data.SqlServer.Managers.SqlContactRecordsManager.<SaveContactIdentifierIndexRecords>d__29
.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System
.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Sitecore.Xdb.Collection.Data.SqlServer
.Managers.SqlContactRecordsManager.<TrySaveChangesAsync>d__18.MoveNext()\r\n--- End of stack trace
from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices
.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter
.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.Xdb.Collection.Data.SqlServer
.SqlDataProvider.<Save>d__16.MoveNext()\r\n--- End of stack trace from previous location where
exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at
Sitecore.Xdb.Collection.DataProviderCountersDecorator.<Save>d__24.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices
.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter
.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.Xdb.Collection.Repository.<Save>d__12.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices
.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.XConnect.Service
.RepositorySaveOperationInvoker.<Execute>d__10.MoveNext()",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nDo\nMicrosoft.Azure.SqlDatabase.ElasticScale.Client, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null\nMicrosoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreOperationGlobal\nMicrosoft.Azure.SqlDatabase.ElasticScale.ShardManagement.IStoreResults Do()",
"HResult": -2146233088,
"Source": "Microsoft.Azure.SqlDatabase.ElasticScale.Client",
"WatsonBuckets": null
}
}
]
}
]
}