/// <summary> /// Inserts the log. /// </summary> /// <returns>The log.</returns> /// <param name="menssage">Menssage.</param> /// <param name="type">Type.</param> /// <param name="policy">Policy.</param> private static async Task <bool> InsertLog(string menssage, TypeLog type, Pilicy policy) { try { if (client == null) { client = new HttpClient(); client.MaxResponseContentBufferSize = 256000; Uri = SettingsApp.Data.Services.ApiRestLog; } var uri = new Uri(Uri); var json = JsonConvert.SerializeObject(new Entities.Log { Description = menssage, Type = type.ToString(), Policy = policy.ToString() }); var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, content); } catch (Exception ex) { //No se realiza ninguna accion } return(true); }
private void setLog(TypeLog type, string log) { if (logFile != null) { using (StreamWriter sWriter = new StreamWriter(logFile, true)) { sWriter.WriteLine("[" + DateTime.Now + "]" + "[" + type.ToString() + "] " + log); } } }
public void WriteLog(string Caller, string Method, TypeLog Type, string ex) { try { using (StreamWriter w = File.AppendText(fileName)) { w.WriteLine("--------------------------------------------------------------------------------"); w.WriteLine("DateTime: " + DateTime.Now.ToString()); w.WriteLine("Type: " + Type.ToString()); w.WriteLine("Caller: " + Caller); w.WriteLine("Method: " + Method); w.WriteLine("Message: " + ex); w.WriteLine("--------------------------------------------------------------------------------"); } } catch { } }
public void WriteLog(string Caller, string Method, TypeLog Type, Exception ex) { try { using (StreamWriter w = File.AppendText(fileName)) { w.WriteLine("--------------------------------------------------------------------------------"); w.WriteLine("DateTime: " + DateTime.Now.ToString()); w.WriteLine("Type: " + Type.ToString()); w.WriteLine("Caller: " + Caller); w.WriteLine("Method: " + Method); w.WriteLine("Message: " + ex.Message); w.WriteLine("Source: " + ex.Source); w.WriteLine("TargetSite: " + ex.TargetSite); w.WriteLine("StackTrace: " + ex.StackTrace); w.WriteLine("InnerException: " + ex.InnerException); w.WriteLine("--------------------------------------------------------------------------------"); } } catch { } }