Web & mobile development footprints
May 7, 2020
May 28, 2019
RePost: Serilog with StructureMap - ASP.Net Core 2.1
This is just compilation from these sources:
https://www.c-sharpcorner.com/article/file-logging-and-ms-sql-logging-using-serilog-with-asp-net-core-2-0/
https://stackoverflow.com/questions/54715142/serilog-not-writing-to-file-net-core-2-2
https://www.c-sharpcorner.com/article/file-logging-and-ms-sql-logging-using-serilog-with-asp-net-core-2-0/
https://stackoverflow.com/questions/54715142/serilog-not-writing-to-file-net-core-2-2
https://andydote.co.uk/2017/07/28/serilog-context-with-structuremap-and-simpleinjector/
https://carlos.mendible.com/2019/01/14/updated-step-step-serilog-asp-net-core/
https://stackify.com/serilog-tutorial-net-logging/
Required NuGet:
Serilog.AspNetCore
Serilog.Extensions.Logging
Serilog.Sinks.File
Example of Program.cs
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Error()
.WriteTo.File("log.txt", rollingInterval: RollingInterval.Day,rollOnFileSizeLimit:true,fileSizeLimitBytes:10000000)
.CreateLogger();
try
{
BuildWebHost(args).Run();
}
finally
{
Log.CloseAndFlush();
}
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSerilog()
.UseStartup<Startup>()
.Build();
}
Startup.cs:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
....
return ConfigureIoc(services);
}
public IServiceProvider ConfigureIoc(IServiceCollection services)
{
var container = new Container(config =>
{
config.Scan(_ =>
{
_.AssemblyContainingType(typeof(Startup));
_.AssembliesAndExecutablesFromApplicationBaseDirectory();
_.WithDefaultConventions();
});
config.For<ILogger>().Use(context => Log.ForContext(context.ParentType));
config.Populate(services);
});
return container.GetInstance<IServiceProvider>();
}
How to use:
private readonly ILogger<MyClass> _logger = null;
public MyClass(
ILogger<MyClass> logger
)
{
_logger = logger;
May 9, 2019
Apr 19, 2019
Bootstrap 4 checkbox change jquery javascript
isCreditCardPaymentSelector: "input[name = 'IsCreditCardPayment']",
isCreditCardPaymentIdSelector: "input[name='IsCreditCardPayment'][type='hidden']",
isCreditCardPaymentIdSelector: "input[name='IsCreditCardPayment'][type='hidden']",
form.find(options.isCreditCardPaymentSelector).removeAttr('checked'); form.find(options.isCreditCardPaymentSelector).parent('label').removeClass('active');
form.find(options.isCreditCardPaymentIdSelector).val(false);
Feb 12, 2019
Subscribe to:
Posts (Atom)