protected async override void Append(LoggingEvent loggingEvent) { try { HttpResponseMessage response; using (var client = new HttpClient()) { LoggingItems log = new LoggingItems() { AppId = 1, Level = loggingEvent.Level.ToString(), Thread = loggingEvent.ThreadName, Message = loggingEvent.RenderedMessage, Timestamp = loggingEvent.TimeStamp, Class = loggingEvent.LoggerName, }; response = await client.PostAsJsonAsync($"https://localhost:44379/v1/AddLoggingItems", log); response.EnsureSuccessStatusCode(); } } catch (Exception ex) { log.Warn(ex.Message); } }
public ActionResult <LoggingItems> AddLoggingItems(LoggingItems items) { if (items == null) { return(NotFound()); } if (ModelState.IsValid) { _context.Logs.Add(items); _context.SaveChanges(); } else { return(BadRequest()); } return(items); }