private void Log <TActivityEnum>( TActivityEnum activityEnum, string?keyType, int?keyId, int?accountId, object?additionalData, string message, params object[] messageData) { // call to get tenant, profile id and account id var tenantId = _tenantProvider.GetTenantId(); var profileId = _profileProvider.GetProfileId(); var properties = new List <ILogEventEnricher> { new PropertyEnricher(Constants.SourceContextPropertyName, typeof(TSourceContext)), new PropertyEnricher("Version", _version), new PropertyEnricher("ActivityType", activityEnum !.ToString()), new PropertyEnricher("TenantId", tenantId), new PropertyEnricher("ProfileId", profileId), new PropertyEnricher(ActivityLoggerLogConfigurationAdapter.LogTypeKey, _activityLogType) }; if (keyId != null) { properties.Add(new PropertyEnricher("KeyId", keyId)); } if (keyType != null) { properties.Add(new PropertyEnricher("keyType", keyType)); } if (additionalData != null) { properties.Add(new PropertyEnricher("AdditionalProperties", additionalData, true)); } if (accountId != null) { properties.Add(new PropertyEnricher("AccountId", accountId)); } try { using (LogContext.Push(properties.ToArray())) { _logger.Information(message, messageData); } } catch (Exception e) { _logger.Error("Error activity logging: {message}", e.Message, e); } } }