コード例 #1
0
        public void LogLine()
        {
            var logger = new Log4NetLogger();
            //BasicConfigurator.Configure();

            logger.Info("test {0}", "bla");
        }
コード例 #2
0
 public void Error(Exception error)
 {
     allLogLines.Error(error);
     var logger = new Log4NetLogger();
     try
     {
         File.WriteAllLines("log.txt", allLogLines.Lines);
         var body = string.Format("<pre>Fout: {0}\n\n{1}</pre>", error.Message, error.StackTrace);
         new SmtpMailer(logger, config).Send(emailAddress.Split(','), "DeCorrespondent.exe. Fout opgetreden", body,
             new Func<FileStream>[] {() => new FileStream("log.txt", FileMode.Open)});
     }
     catch (Exception e)
     {
         logger.Error(e);
         logger.Error(error);
     }
     finally
     {
         if (File.Exists("log.txt"))
             File.Delete("log.txt");
     }
 }
コード例 #3
0
 public static void Main(string[] args)
 {
     var config = FileConfig.Load(null);
     var arguments = HandleArguments(args, config);
     if (!arguments.RunProgram)
         return;
     ILogger logger = new Log4NetLogger();
     try
     {
         logger = new CompositeLogger(logger, new EmailErrorLogger(config.NotificationEmail, config.SmtpMailConfig));
         var login = !string.IsNullOrEmpty(config.DeCorrespondentReaderConfig.Username);
         using (var session = (login ? DeCorrespondentResources.Login(config.DeCorrespondentReaderConfig, logger) : RssFeedResources.Instance(logger)))
         {
             var p = Program.Instance(arguments, logger, session, config);
             var pdfs = p.ReadDeCorrespondentAndWritePdfs();
             p.SendToKindleAndSendNotificationMail(pdfs);
             pdfs.Select(pdf => pdf.FileName).ToList().ForEach(p.DeleteFile);
         }
     }
     catch (Exception e)
     {
         logger.Error(e);
     }
 }