Esempio n. 1
0
 public void LogDataBase(string stackTrace)
 {
     try
     {
         var log = new LogSistema()
         {
             StackTrace = stackTrace,
             Tipo       = TipoLog.BancoDados
         };
         LogSistemaRepository.Save(log);
     }
     catch (Exception ex)
     {
         LogService(ex);
     }
 }
Esempio n. 2
0
        public void LogService(Exception ex)
        {
            try
            {
                var log = new LogSistema()
                {
                    StackTrace = Utils.GetStackTrace(ex),
                    Tipo       = TipoLog.Servidor
                };
                LogSistemaRepository.Save(log);
            }
            catch (Exception exception)
            {
                var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\log\\";
                dir = dir.Replace("file:\\", "");
                var file = dir + "Log " + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                Utils.GravarArquivo(file, Utils.GetStackTrace(exception));
            }
        }