public void LogFunctionTraceEvent(LogLevel level, string subscriptionId, string appName, string functionName, string eventName, string source, string details, string summary, string exceptionType, string exceptionMessage, string functionInvocationId, string hostInstanceId, string activityId, string runtimeSiteName, string slotName, DateTime eventTimeStamp)
        {
            if (!FunctionsSystemLogsEventSource.Instance.IsEnabled())
            {
                return;
            }

            string formattedEventTimestamp = eventTimeStamp.ToString(EventTimestampFormat);

            using (FunctionsSystemLogsEventSource.SetActivityId(activityId))
            {
                switch (level)
                {
                case LogLevel.Trace:
                case LogLevel.Debug:
                    FunctionsSystemLogsEventSource.Instance.RaiseFunctionsEventVerbose(subscriptionId, appName, functionName, eventName, source, details, summary, ScriptHost.Version, formattedEventTimestamp, functionInvocationId, hostInstanceId, runtimeSiteName, slotName);
                    break;

                case LogLevel.Information:
                    FunctionsSystemLogsEventSource.Instance.RaiseFunctionsEventInfo(subscriptionId, appName, functionName, eventName, source, details, summary, ScriptHost.Version, formattedEventTimestamp, functionInvocationId, hostInstanceId, runtimeSiteName, slotName);
                    break;

                case LogLevel.Warning:
                    FunctionsSystemLogsEventSource.Instance.RaiseFunctionsEventWarning(subscriptionId, appName, functionName, eventName, source, details, summary, ScriptHost.Version, formattedEventTimestamp, functionInvocationId, hostInstanceId, runtimeSiteName, slotName);
                    break;

                case LogLevel.Error:
                case LogLevel.Critical:
                    FunctionsSystemLogsEventSource.Instance.RaiseFunctionsEventError(subscriptionId, appName, functionName, eventName, source, details, summary, ScriptHost.Version, formattedEventTimestamp, exceptionType, exceptionMessage, functionInvocationId, hostInstanceId, runtimeSiteName, slotName);
                    break;
                }
            }
        }
示例#2
0
        public override void LogFunctionTraceEvent(LogLevel level, string subscriptionId, string appName, string functionName, string eventName, string source, string details, string summary, string exceptionType, string exceptionMessage, string functionInvocationId, string hostInstanceId, string activityId, string runtimeSiteName, string slotName, DateTime eventTimestamp)
        {
            using (FunctionsSystemLogsEventSource.SetActivityId(activityId))
            {
                details = details.Length > MaxDetailsLength?details.Substring(0, MaxDetailsLength) : details;

                // Set event type to MS_FUNCTION_LOGS to send these events as part of infra logs.
                JObject traceLog = new JObject();
                traceLog.Add("EventType", ScriptConstants.LinuxLogEventStreamName);
                traceLog.Add("Level", (int)ToEventLevel(level));
                traceLog.Add("SubscriptionId", subscriptionId);
                traceLog.Add("AppName", appName);
                traceLog.Add("FunctionName", functionName);
                traceLog.Add("EventName", eventName);
                traceLog.Add("Source", source);
                traceLog.Add("Details", NormalizeString(details));
                traceLog.Add("Summary", NormalizeString(summary));
                traceLog.Add("HostVersion", ScriptHost.Version);
                traceLog.Add("EventTimeStamp", eventTimestamp.ToString(EventTimestampFormat));
                traceLog.Add("ExceptionType", exceptionType);
                traceLog.Add("ExceptionMessage", NormalizeString(exceptionMessage));
                traceLog.Add("FunctionInvocationId", functionInvocationId);
                traceLog.Add("HostInstanceId", hostInstanceId);
                traceLog.Add("ActivityId", activityId);
                traceLog.Add("RuntimeSiteName", runtimeSiteName);
                traceLog.Add("SlotName", slotName);

                _writeEvent(traceLog.ToString(Formatting.None));
            }
        }
        public override void LogFunctionTraceEvent(LogLevel level, string subscriptionId, string appName, string functionName, string eventName, string source, string details, string summary, string exceptionType, string exceptionMessage, string functionInvocationId, string hostInstanceId, string activityId, string runtimeSiteName, string slotName, DateTime eventTimestamp)
        {
            string formattedEventTimeStamp = eventTimestamp.ToString(EventTimestampFormat);
            string hostVersion             = ScriptHost.Version;

            using (FunctionsSystemLogsEventSource.SetActivityId(activityId))
            {
                details = details.Length > MaxDetailsLength?details.Substring(0, MaxDetailsLength) : details;

                _writeEvent($"{ScriptConstants.LinuxLogEventStreamName} {(int)ToEventLevel(level)},{subscriptionId},{appName},{functionName},{eventName},{source},{NormalizeString(details)},{NormalizeString(summary)},{hostVersion},{formattedEventTimeStamp},{exceptionType},{NormalizeString(exceptionMessage)},{functionInvocationId},{hostInstanceId},{activityId},{_containerName},{StampName},{TenantId},{runtimeSiteName},{slotName}");
            }
        }
        public override void LogFunctionTraceEvent(LogLevel level, string subscriptionId, string appName, string functionName, string eventName,
                                                   string source, string details, string summary, string exceptionType, string exceptionMessage,
                                                   string functionInvocationId, string hostInstanceId, string activityId, string runtimeSiteName, string slotName, DateTime eventTimestamp)
        {
            var formattedEventTimestamp = eventTimestamp.ToString(EventTimestampFormat);
            var hostVersion             = ScriptHost.Version;
            var hostName = _hostNameProvider.Value;

            using (FunctionsSystemLogsEventSource.SetActivityId(activityId))
            {
                var logger = _loggerFactory.GetOrCreate(FunctionsLogsCategory);
                WriteEvent(logger, $"{(int)ToEventLevel(level)},{subscriptionId},{hostName},{appName},{functionName},{eventName},{source},{NormalizeString(details)},{NormalizeString(summary)},{hostVersion},{formattedEventTimestamp},{exceptionType},{NormalizeString(exceptionMessage)},{functionInvocationId},{hostInstanceId},{activityId}");
            }
        }