/// <summary> /// Запись в Файл /// </summary> private static async Task WriteInFileAsync() { await Task.Run(() => { var loggingFile = new LoggingFile(); loggingFile.WriteData(DateTime.Now, GetMemorySize()); }); }
public async Task InvokeAsync(HttpContext context, IDbService writterService) { LoggingFile file = null; if (context.Request != null) { file = new LoggingFile(); file.path = context.Request.Path; file.method = context.Request.Method; file.queryString = context.Request.QueryString.ToString(); file.body = ""; using (StreamReader reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, true)) { file.body = await reader.ReadToEndAsync(); } writterService.SaveLogData(file); } if (_next != null) { await _next(context); } }
public TextLogger() { _loggingFile = new LoggingFile(); }
public void SaveLogData(LoggingFile loggingFile) { var jsonString = JsonSerializer.Serialize(loggingFile, typeof(LoggingFile)); File.WriteAllText($"{Statics.StaticValues.LOGGING_FILE_PATH}", jsonString, Encoding.UTF8); }
/// <summary> /// Получить данные из файла. /// </summary> /// <param name="source"></param> /// <param name="e"></param> /// <returns></returns> private static List <Log> GetFromFile() { var loggingFile = new LoggingFile(); return(loggingFile.GetData()); }