//const string OutTemplate = " {Environment} | {Timestamp:yyyy-MM-dd HH:mm:ss} | [{Level}] | {Bookmark} | {Message}{NewLine}{Exception}"; //-------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------- static void Main(string[] args) { var serilog = new LoggerConfiguration() .Enrich.With(new ApplicationDetailsEnricher()) .WriteTo.Console(outputTemplate: OutTemplate) .Enrich.WithProperty("Environment", "Developer") .Enrich.FromLogContext() .CreateLogger(); var logger = new StructuredLog(serilog, new ElasticConfig(uri: "http://*****:*****@item}", item)); //using (LogContext.PushProperty(SerilogBookmarkBase.LableName, "stam")) //{ // logger.Information("line {@item}", item); //} } logger.PrintSeperator(); var cartLog = Log.ForContext <Program>(); foreach (var item in list) { logger.ToTraceInfo <ArkIntegrationTest>(x => x.XXX) .MarkOn <ArkIntegrationTest>(x => x.XXX) .MarkOn("ssss") .Mark(x => x.Information("line {@item}", item)); //logger.Information("line {@item}", item); } logger.PrintSeperator(); var traceinfo = logger.ToTraceInfo <ArkIntegrationTest>(x => x.Test).MarkOn <ArkIntegrationTest>(x => x.XXX); foreach (var item in list) { traceinfo.Mark(x => x.Information("line {@item}", item)); } traceinfo = traceinfo.MarkOn <ArkIntegrationTest>(x => x.Test3); foreach (var item in list) { traceinfo.Mark(x => x.Information("line {@item}", item)); } Console.ReadKey(); }
private static IContainer InitDi() { //var uri = new Uri("http://localhost:9200"); //var settings = new ConnectionSettings(uri).DefaultIndex("ark-personstorage"); //var elasticLowLevelClient = new ElasticLowLevelClient(settings); //var client = new ElasticClient(settings); var elasticSearchConfig = new ElasticConfig(uri: "http://localhost:9200", index: "ark-personstorage"); var structuredLogger = new StructuredLog(_logger, elasticSearchConfig); var container = new ContainerBuilder(); container.Register <IStructuredLog>(x => structuredLogger); container.RegisterType <ElasticSearchScenario>(); container.Register(x => elasticSearchConfig); return(container.Build()); }