Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The master branch not work with asp.net core #13

Open
JasonLiuLiuLiuLiu opened this issue Jul 4, 2019 · 1 comment
Open

The master branch not work with asp.net core #13

JasonLiuLiuLiuLiu opened this issue Jul 4, 2019 · 1 comment

Comments

@JasonLiuLiuLiuLiu
Copy link

Hi saleem,

it seems master banch can't work with asp.net core, and the latest nuget also not work, but when i switch to dev branch, it worked. I tried to find the root cause but didn't find it. Do you know the reason?

@JasonLiuLiuLiuLiu
Copy link
Author

there is the program code.

    public class Program
    {
        public static void Main(string[] args)
        {
            args.SetConfigInfo();

            var logConfig = new LoggerConfiguration()
#if DEBUG
                .MinimumLevel.Debug()
                .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
#else
                .MinimumLevel.Information()
                .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
#endif
                .Enrich.FromLogContext();

            logConfig = ConfigDataHelper.TryGetConnectionString("iBlogs", out var connectionString) ?
                logConfig.WriteTo.MySQL(connectionString) : logConfig.WriteTo.Console();

            Log.Logger = logConfig.CreateLogger();

            try
            {
                Log.Information("Starting web host");
                CreateWebHostBuilder(args).Build().Run();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((hostingContext, config) =>
                {
                    config.SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                        .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
                        .AddEnvironmentVariables()
                        .AddCommandLine(args);
                })
                .UseStartup<Startup>()
                .UseSerilog();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant