public async Task LogForUser(string userId, string message, DigitTraceAction action = DigitTraceAction.Default, IDictionary <string, object> additionalData = null, LogLevel logLevel = LogLevel.Information) { var telemetry = new TraceTelemetry(message, FromLogLevel(logLevel)); if (null != additionalData) { foreach (var prop in additionalData) { telemetry.Properties.Add(prop.Key, prop.Value.ToString()); } } telemetry.Properties.Add("digitTraceAction", action.ToString()); telemetry.Context.User.Id = userId; string id = Guid.NewGuid().ToString(); telemetry.Properties.Add("digitTraceId", id); _telemetryClient.TrackTrace(telemetry); var e = new LogEntry() { UserId = userId, AdditionalData = telemetry.Properties, Author = "digit-svc", DigitTraceAction = action, FocusItemId = telemetry.Properties.ContainsKey("focusItemId") ? telemetry.Properties["focusItemId"] : null, Id = id, LogLevel = logLevel, Message = message, Timestamp = DateTimeOffset.Now }; await Task.WhenAll(_subscribers.Select(s => s.Add(e))); }