---
title: "xConnect操作ログの設定"
slug: "configure-xconnect-operation-logging"
abstract: "xConnect操作ログを設定して、xConnectのコマンドや操作の状態を追跡する方法。"
---
# xConnect操作ログの設定

拡張されたxConnectログには、xConnectコマンドの実行前後の操作状態の追跡が含まれます。

各操作は一意のバッチIDを持っています。操作が失敗した場合、前任および後継操作の操作IDもログに記録されます。デフォルトでは無効化されています。

xConnect操作のログ出力には、各コマンド実行のログエントリとBatchIdフィールドが含まれています。関連するコマンドのログはこのBatchIdで見つけることができます。

ログ出力は以下の通りです:

-   バッチのID。
-   作戦名。
-   バッチ内のオペレーションID。
-   作戦の進行状況。
-   操作パラメータ(例えば、連絡先ID、識別子フィールド、ファセット情報など)。
-   前身または後継機のオペレーションID。

## xConnect操作ログを有効にする

xConnect操作ログングを有効にするには:

-   ファイル名を\\App\_Data\\Config\\Sitecore\\Collection\\sc.XConnect.Collection.Web.Logging.xmlに変えて\\App\_Data\\Config\\Sitecore\\Collection\\sc.XConnect.Collection.Web.Logging.xml.disabledを有効にしてください。

### xConnect操作ログの例

xConnect操作のログ出力には、各コマンド実行のログエントリが含まれています。例えば:

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 "
 }
 
 }
 
}

## ログレベルを変えてください

xConnect操作が実行中に例外を投げた場合、以下のいずれかのタイプをログに記録します。

-   Only type (例外の種類のみ)
-   Medium (例外の型とメッセージ)
-   Full (例外インスタンスに含まれる完全な情報)

デフォルトでは、ログタイプレベルはMediumです。

ログタイプのレベルを変更するには:

-   設定ファイルを開いて\\App\_Data\\Config\\Sitecore\\Collection\\sc.XConnect.Collection.Web.Logging.xmlSettings/Sitecore/XConnect/Collection/Services/ExceptionLogFormatter/Options/ExceptionLogLevelノードの値を変更してください。
    
    <ExceptionLogLevel>Medium</ExceptionLogLevel>
    

### OnlyTypeレベルの例外例

以下はOnlyTypeログレベルのログ出力の例です。

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ログレベルのログ出力の例です。

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.ExecuteActionTResult(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ログレベルのログ出力の例です。

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.ExecuteActionTResult(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.AddOrGetExistingFromCacheT(String key, Func\`1 valueFactory)\\r\\n at
 Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.MapRecordsToShardsT
 (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
 }
 }
 
 }
 
}