You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like the "Timestamp" in this format or the closest 2024-03-01 18:07:27.251
I have already managed to change my Created_date column to use timestamp and add custom properties to the Properties key, but I will prefer to modify the existing "Timestamp"
Here is the Serilog configuration if needed
publicstaticclassSerilogExtensions{conststringTableName="Log_API";conststringSchemaName="Serilog";conststringoutputTemplate="[{Timestamp:u} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{record}{NewLine}{Exception}";/// <summary>/// Defines the serilog configuration/// </summary>/// <param name="builder">WebApplicationBuilder for adding services to the builder</param>publicstaticvoidAddSerilogApi(WebApplicationBuilderbuilder){IConfiguration?configuration=builder.Configuration;stringConnectionString=configuration![Enum.GetName(typeof(CxCloudDbContext.DataContext.DbContextType),1)!]!;varSettingAppInsights=builder.Configuration.GetSection(nameof(SettingApplicationInsights)).Get<SettingApplicationInsights>();IDictionary<string,ColumnWriterBase>ColumnOptions=newDictionary<string,ColumnWriterBase>{{"RequestId",newRenderedMessageColumnWriter(NpgsqlDbType.Varchar)},{"Level",newLevelColumnWriter(true,NpgsqlDbType.Varchar)},{"Created_date",newTimestampColumnWriter(NpgsqlDbType.Timestamp)},{"Exception",newExceptionColumnWriter(NpgsqlDbType.Text)},{"Log_event",newLogEventSerializedColumnWriter(NpgsqlDbType.Jsonb)},{"Properties",newPropertiesColumnWriter(NpgsqlDbType.Jsonb)},{"Machine_name",newSinglePropertyColumnWriter("MachineName",PropertyWriteMethod.ToString,NpgsqlDbType.Text,"l")}};Log.Logger=newLoggerConfiguration().ReadFrom.Configuration(configuration).MinimumLevel.Override("Microsoft.AspNetCore",LogEventLevel.Error).Enrich.FromGlobalLogContext().Enrich.FromLogContext().Enrich.WithThreadId().Enrich.WithClientIp().Enrich.WithProcessName().Enrich.WithMachineName().Enrich.WithEnvironmentUserName().Enrich.WithExceptionDetails().Destructure.JsonNetTypes().WriteTo.Async(wt =>wt.Console(outputTemplate:outputTemplate)).WriteTo.Async(appInsgh =>appInsgh.ApplicationInsights(SettingAppInsights.ConnectionString,newTraceTelemetryConverter())).WriteTo.Async(pg =>pg.PostgreSQL(ConnectionString,TableName,ColumnOptions,needAutoCreateTable:false,needAutoCreateSchema:false,schemaName:SchemaName,useCopy:true,period:newTimeSpan(0,0,10),restrictedToMinimumLevel:LogEventLevel.Information)).CreateLogger();builder.Host.UseSerilog();}}
The text was updated successfully, but these errors were encountered:
Hello everyone
Is there a way, preferably trough code, to configure the "Timestamp" property to be UTC?
Currently my the JSON looks like this:
I would like the "Timestamp" in this format or the closest
2024-03-01 18:07:27.251
I have already managed to change my Created_date column to use
timestamp
and add custom properties to the Properties key, but I will prefer to modify the existing "Timestamp"Here is the Serilog configuration if needed
The text was updated successfully, but these errors were encountered: