protected void Application_Start() { AreaRegistration.RegisterAllAreas(); ConfigureApi(GlobalConfiguration.Configuration); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var logManager = new Common.Logging.LogManager(); var log = logManager.GetLogger((typeof(WebApiApplication))); try { var dataContext = new AnimalsDataContext(); dataContext.Database.CommandTimeout = _extendedConnectionTimeoutForBulkDataSeeding; dataContext.Database.Initialize(true); dataContext.Database.CommandTimeout = _defaultConnectionTimeout; } catch (SqlException e) { log.Error("SQL Exception - mostly likely the database is in use and can't be dropped and initialised", e); } log.Info(Common.Constants.SiteNames.DOGSTORE_SITE_NAME + " Service API is starting up and database initialisation is complete"); }
// GET: Home public ActionResult Index() { GlobalDiagnosticsContext.Set("Application", "LoggerPerfTestWeb"); var sb = new StringBuilder(); var logger = LogManager.GetLogger("PerfTest"); //var logger = LogManager.GetLogger("PerfTestCrash"); var log4mb = System.IO.File.ReadAllText(Server.MapPath("~/bin/4MB.txt")); var nb4mb = 1000; long duration4mb; var sw = new Stopwatch(); sb.AppendLine($"Start {nb4mb} 4MB logs."); sw.Start(); for (int i = 0; i < nb4mb; i++) { logger.Info(log4mb); } sw.Stop(); duration4mb = sw.ElapsedMilliseconds; sb.AppendLine($"{nb4mb} 4MB logs in {duration4mb}ms."); var proc = Process.GetCurrentProcess(); sb.AppendLine($"PrivateMemorySize = {proc.PrivateMemorySize64}"); sb.AppendLine($"VirtualMemorySize = {proc.VirtualMemorySize64}"); sb.AppendLine($"PeakVirtualMemorySize = {proc.PeakVirtualMemorySize64}"); sb.AppendLine($"PagedMemorySize = {proc.PagedMemorySize64}"); sb.AppendLine($"PeakPagedMemorySize = {proc.PeakPagedMemorySize64}"); return(Content(sb.ToString())); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); Bootstrapper.Initialise(); var logManager = new Common.Logging.LogManager(); var log = logManager.GetLogger((typeof(MvcApplication))); if (log.IsInfoEnabled) log.Info(Common.Constants.SiteNames.DOGSTORE_SITE_NAME + " Web application is starting up"); }
public override int SaveChanges() { ApplyRules(); try { return base.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException e) { foreach (var entityValidationError in e.EntityValidationErrors) { var logManager = new Common.Logging.LogManager(); var log = logManager.GetLogger((typeof(AnimalsDataContext))); log.Error("Entity Validation Error in configuring test data " + entityValidationError.Entry + ", " + entityValidationError.ValidationErrors, e); } throw e; } }
static void Main(string[] args) { var config = new LoggingConfiguration(); var consoleTarget = new ColoredConsoleTarget(); config.AddTarget("console", consoleTarget); var fileTarget = new FileTarget(); config.AddTarget("file", fileTarget); consoleTarget.Layout = @"${message}"; fileTarget.FileName = "${basedir}/Logging/log.txt"; fileTarget.Layout = @"${date:format=HH\:mm\:ss} ${logger} ${message}"; LoggingRule consoleRule = new LoggingRule("*", LogLevel.Debug, consoleTarget); LoggingRule fileRule = new LoggingRule("*", LogLevel.Debug, fileTarget); config.LoggingRules.Add(consoleRule); config.LoggingRules.Add(fileRule); // Step 5. Activate the configuration LogManager.Configuration = config; var logger = Common.Logging.LogManager.GetLogger <Program>(); var logManager = new Common.Logging.LogManager(); Quirks.Logging.Logger.Initialize(logger); TrollTyper t = new TrollTyper(args); if (!t.Run()) { Console.Write("\nPress any key to exit..."); Console.ReadKey(); } }
public GroupController(Common.Logging.LogManager logManager, MessageService messageService, ApiContext apiContext) { LogManager = logManager; MessageService = messageService; ApiContext = apiContext; }