private void Log(SeverityEnum severity, string message, Exception exception = null)
 {
     Console.WriteLine($"{severity.ToString()}:{message}");
     if (exception != null)
     {
         Console.WriteLine($"Stack Trace : {exception.StackTrace}");
     }
 }
예제 #2
0
 public override void Write(SeverityEnum severity, string message)
 {
     using (DatabaseLoggerContext context = new DatabaseLoggerContext())
     {
         context.Logs.Add(new DatabaseLogs
         {
             Severity = severity.ToString(),
             Message  = message,
             Time     = DateTime.Now
         });
         context.SaveChanges();
     }
 }
 private void Log(SeverityEnum severity, string message, Exception exception = null)
 {
     try
     {
         using (TextWriter tw = new StreamWriter(LogFileName, true))
         {
             tw.WriteLine(doubleDivider);
             tw.WriteLine($"Log Entry: @ {DateTime.Now.ToLongTimeString()} {DateTime.Now.ToLongDateString()}");
             tw.WriteLine(singleDivider);
             tw.WriteLine($"{severity.ToString()}:{message}");
             if (exception != null)
             {
                 tw.WriteLine($"Stack Trace : {exception.StackTrace}");
             }
             tw.WriteLine(doubleDivider);
         }
     }
     catch (Exception ex)
     {
         //Where to log?
     }
 }
예제 #4
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement impactNode = document.CreateElement("idmef:Impact", "http://iana.org/idmef");

            if (severity != SeverityEnum.undefined)
            {
                impactNode.SetAttribute("severity", severity.ToString());
            }
            if (completion != CompletionEnum.undefined)
            {
                impactNode.SetAttribute("completion", completion.ToString());
            }
            impactNode.SetAttribute("type", assessmentType.ToString());

            if ((description != null) && (description.Length > 0))
            {
                XmlNode impactSubNode = document
                                        .CreateNode(XmlNodeType.Text, "idmef", "Impact", "http://iana.org/idmef");
                impactSubNode.Value = description;
                impactNode.AppendChild(impactSubNode);
            }

            return(impactNode);
        }