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

Error Message column does not exist #104

Closed
drlowery opened this issue Jan 12, 2024 · 4 comments · Fixed by #105
Closed

Error Message column does not exist #104

drlowery opened this issue Jan 12, 2024 · 4 comments · Fixed by #105
Assignees
Labels
enhancement New feature or request

Comments

@drlowery
Copy link

drlowery commented Jan 12, 2024

Using Postgresql provider I get the error message:

"errorMessage": "{"errorMessage":"42703: column \"message\" does not exist\r\n\r\nPOSITION: 8"}"

The column does exist in the table.

.net core 7, web api project
serilog.sinks.postgresql.alternative 4.0.2
serilog.ui.postgresqlprovider 2.2.2

table schema
CREATE TABLE IF NOT EXISTS "Logs" (
"Message" TEXT,
"MessageTemplate" TEXT,
"Level" INTEGER,
"Timestamp" TIMESTAMP WITH TIME ZONE,
"Exception" TEXT,
"LogEvent" JSONB
) USING HEAP;

builder.Services.AddSerilogUi(options =>
{
options.UseNpgSql(dbSettings["ConnectionString"], "Logs", "public");
});

What am I missing?

Thanks!

@mo-esmp mo-esmp self-assigned this Jan 12, 2024
@mo-esmp
Copy link
Member

mo-esmp commented Jan 12, 2024

Thanks for reporting the issue. The current PostgreSQL data provider is based on the serilog-sinks-postgresql sink and we need to introduce a new package for serilog.sinks.postgresql.alternative sink because they use a different table schema for saving logs.

@mo-esmp mo-esmp added the enhancement New feature or request label Jan 12, 2024
@drlowery
Copy link
Author

AH thanks, had to use the alternative for another issue.
Thanks again for the quick answer.
Will keep a on the look out for the support to alterative

@drlowery
Copy link
Author

to help others I got this to work with serilog.sinks.postgresql.alternative

Add column writer definitions

IDictionary<string, ColumnWriterBase> columnWriters = new Dictionary<string, ColumnWriterBase>
{
{"message", new RenderedMessageColumnWriter(NpgsqlDbType.Text) },
{"message_template", new MessageTemplateColumnWriter(NpgsqlDbType.Text) },
{"level", new LevelColumnWriter(false, NpgsqlDbType.Integer) },
{"timestamp", new TimestampColumnWriter(NpgsqlDbType.Timestamp) },
{"exception", new ExceptionColumnWriter(NpgsqlDbType.Text) },
{"log_event", new LogEventSerializedColumnWriter(NpgsqlDbType.Jsonb) }
};

the configure with the writers

            loggerConfiguration.WriteTo.PostgreSQL(
                dbSettings["ConnectionString"] ?? "",
                tableName: "logs",
                columnWriters,
                needAutoCreateTable: true,
                schemaName: "public");

Then the normal usage of serilog-ui will work fine.
It matches the lower-case of the column names and schema

mo-esmp added a commit that referenced this issue Jan 26, 2024
* Add query builder for PostgreSQL alternative sink.
* Add unit tests for query builder.
* Fix query builder.
* Remove extra code.
* Fix XML doc.
* Move model classes to Models folder.
* Fix models namespace.
---------
@mo-esmp
Copy link
Member

mo-esmp commented Jan 26, 2024

Please upgrade Serilog.UI.PostgreSqlProvider nuget package to version 2.3.0.

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

Successfully merging a pull request may close this issue.

2 participants