Пример #1
0
        static void Main()
        {
            CurrentDirectoryAssemblyLoader.Install();

            Log.Logger = new LoggerConfiguration()
                .ReadFrom.CommandLine()
                .Enrich.WithThreadId()
                .Enrich.WithProperty("Application", "e-Commerce")
                .Enrich.With<SerialNumberEnricher>()
                .MinimumLevel.Debug()
                .CreateLogger();

            const int initialCustomers = 1;
            Log.Information("Simulation starting with {InitialCustomers} initial customers...", initialCustomers);

            var catalog = new Catalog();

            var customers = new ConcurrentBag<Customer>(Enumerable.Range(0, initialCustomers)
                .Select(_ => new Customer(catalog)));

            var traffic = new TrafficReferral(customers, catalog);
            var admin = new Administrator(catalog);

            foreach (var c in customers)
                c.Start();

            admin.Start();
            traffic.Start();

            Log.Information("Simulation running, press any key to exit.");
            var k = Console.ReadKey(true);
            Log.Information("Simulation stopped ({@KeyInfo})", k);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
               .WriteTo.LiterateConsole()
               .WriteTo.DynamoDB("Log-Dev")
               .Enrich.WithThreadId()
               .Enrich.WithProperty("Serilog.Sinks.DynamoDB.Sample", "Sample App")
               .MinimumLevel.Debug()
               .CreateLogger();

              Log.Information("Testing Dynamo DB");
              Log.Error(new AbandonedMutexException("Hello"), "An exception from the Serilog DynamoDB Sample");

              const int initialCustomers = 1;
              var catalog = new Catalog();

              var customers = new ConcurrentBag<Customer>(Enumerable.Range(0, initialCustomers)
              .Select(_ => new Customer(catalog)));

              var traffic = new TrafficReferral(customers, catalog);
              var admin = new Administrator(catalog);

              foreach (var c in customers)
              c.Start();

              admin.Start();
              traffic.Start();

              Console.ReadLine();
        }
Пример #3
0
        public void Run()
        {
            const int initialCustomers = 1;

            Log.Information("Simulation starting with {InitialCustomers} initial customers...", initialCustomers);

            var catalog = new Catalog();

            var customers = new ConcurrentBag<Customer>(Enumerable.Range(0, initialCustomers)
                .Select(_ => new Customer(catalog)));

            var traffic = new TrafficReferral(customers, catalog);
            var admin = new Administrator(catalog);

            foreach (var c in customers)
                c.Start();

            admin.Start();
            traffic.Start();
        }