Ejemplo n.º 1
0
        private static void BaseLog(LogLevel logLevel, Dictionary <LogProperties, object> dataDictionary = null)
        {
            if (dataDictionary == null)
            {
                dataDictionary = new Dictionary <LogProperties, object>();
            }

            SlackLogger.PostMessage(logLevel, dataDictionary);
            using (var eventLog = new EventLog("Matlab.Logger"))
            {
                eventLog.Source = "Matlab.Logger";
                eventLog.Log    = "Application";

                string message = "";
                foreach (var valuePair in dataDictionary)
                {
                    message += $"{valuePair.Key}: {valuePair.Value}\n";
                }

                //eventLog.WriteEntry("Log message example", EventLogEntryType.Information, 101, 1);
                eventLog.WriteEntry(message, logLevel.ConvertToEventLogEntryType(), EventId);
            }

            EventId++;
        }