Exemplo n.º 1
0
        public static List <LoggingEntity> GetLogs()
        {
            List <LoggingEntity> logs       = new List <LoggingEntity>();
            const int            BufferSize = 128;

            using (var fileStream = File.OpenRead(filePath))
                using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize))
                {
                    string line;
                    for (int i = 1; (line = streamReader.ReadLine()) != null; i++)
                    {
                        if (i > logs.Count)
                        {
                            var splittedLine = line.Split(" ");
                            var logLine      = new LoggingEntity(DateTime.Parse(splittedLine[0] + " " + splittedLine[1]),
                                                                 splittedLine[2],
                                                                 splittedLine[3],
                                                                 new Instance(splittedLine[4].Split(":")[0],
                                                                              Int32.Parse(splittedLine[4].Split(":")[1])),
                                                                 splittedLine[5],
                                                                 Int32.Parse(splittedLine[6]));
                            logs.Add(logLine);
                        }
                    }
                }
            return(logs);
        }
Exemplo n.º 2
0
        public static void Log(string requestUrl, string method, Instance instance, string requestToInstanceUrl, int responseStatusCode)
        {
            var loggingEntity = new LoggingEntity(requestUrl, method, instance, requestToInstanceUrl, responseStatusCode);

            Log(loggingEntity);
            using (StreamWriter writer = File.AppendText(filePath))
            {
                writer.WriteLine(loggingEntity.ToString());
            }
        }
Exemplo n.º 3
0
 public static LoggingDto CreateFromEntity(LoggingEntity entity)
 {
     return(new LoggingDto()
     {
         Tags = entity.Tags,
         Id = entity.Id,
         StatusData = entity.StatusData,
         CreateTime = entity.CreateTime
     });
 }
Exemplo n.º 4
0
        //private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

        public void Log(LoggingEntity loggingEntity)
        {
            //LogEventInfo info = new LogEventInfo();
            //info.Level = LogLevel.Info;
            //info.LoggerName = "Error";
            //MappedDiagnosticsContext.Set("MethodName", loggingEntity.MethodName);
            //MappedDiagnosticsContext.Set("Parameters", loggingEntity.Parameters);
            //MappedDiagnosticsContext.Set("ExceptionMessage", loggingEntity.ExceptionMessage);
            //MappedDiagnosticsContext.Set("ExceptionStackTrace", loggingEntity.ExceptionStackTrace);
            //MappedDiagnosticsContext.Set("CreatedBy", loggingEntity.CreatedBy);
            //Logger.Log(info);
        }
Exemplo n.º 5
0
        protected override void SendBuffer(LoggingEvent[] events)
        {
            var groups = events.GroupBy(e => e.LoggerName);

            foreach (var group in groups)
            {
                TableBatchOperation batchOperation = new TableBatchOperation();

                foreach (var e in group)
                {
                    LoggingEntity entity = new LoggingEntity(e)
                    {
                        Message = RenderLoggingEvent(e)
                    };
                    batchOperation.Insert(entity);
                }

                _cloudTable.ExecuteBatch(batchOperation);
            }
        }
Exemplo n.º 6
0
 public void InsertExceptionInformation(LoggingEntity loggingEntity)
 {
     try
     {
         if (loggingEntity.CountryId > 0)
         {
             SqlHelper.countryId = loggingEntity.CountryId;
         }
         SqlHelper.QuerySP("InsertExceptionInformation",
                           new
         {
             MethodName          = loggingEntity.MethodName,
             Parameters          = loggingEntity.Parameters,
             ExceptionMessage    = loggingEntity.ExceptionMessage,
             ExceptionStackTrace = loggingEntity.ExceptionStackTrace,
             CreatedBy           = loggingEntity.CreatedBy
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 7
0
 public static void Log(LoggingEntity loggingEntity)
 {
     logs.Add(loggingEntity);
 }