Describe the bug
When schemaName is passed to WriteTo.PostgreSQL(...) without setting respectCase: true,
the sink emits unquoted identifiers (e.g. CREATE TABLE IF NOT EXISTS Log.Events), which
Postgres case-folds to lowercase (log.events). If the schema actually exists with
preserved case (e.g. created via CREATE SCHEMA "Log" in an EF Core migration), the sink
fails with:
ERROR: schema "log" does not exist at character 28
STATEMENT: CREATE TABLE IF NOT EXISTS Log.Events (...)
This error repeats on every log write attempt and is easy to miss since Serilog sinks fail
silently/internally by default (self-log only). There's no indication that the fix is
respectCase: true unless you already know to check the README.
To Reproduce
- Create a Postgres schema with mixed case, e.g.
CREATE SCHEMA "Log";
- Configure the sink:
.WriteTo.PostgreSQL(connectionString, "Events", schemaName: "Log", needAutoCreateTable: true)
- Observe repeated Postgres errors:
schema "log" does not exist
Expected behavior
Either:
respectCase should default to true (safer default — quoting is a no-op when case
already matches lowercase), or
- The sink should detect a schema-not-found error caused by case folding and emit a clear
self-log warning suggesting respectCase: true, or
- The docs/XML summary on
schemaName parameter should explicitly warn about this instead
of only being covered in the README's general "mixed case" note.
Workaround
Setting respectCase: true explicitly resolves it, as documented in the README.
Describe the bug
When
schemaNameis passed toWriteTo.PostgreSQL(...)without settingrespectCase: true,the sink emits unquoted identifiers (e.g.
CREATE TABLE IF NOT EXISTS Log.Events), whichPostgres case-folds to lowercase (
log.events). If the schema actually exists withpreserved case (e.g. created via
CREATE SCHEMA "Log"in an EF Core migration), the sinkfails with:
This error repeats on every log write attempt and is easy to miss since Serilog sinks fail
silently/internally by default (self-log only). There's no indication that the fix is
respectCase: trueunless you already know to check the README.To Reproduce
CREATE SCHEMA "Log";schema "log" does not existExpected behavior
Either:
respectCaseshould default totrue(safer default — quoting is a no-op when casealready matches lowercase), or
self-log warning suggesting
respectCase: true, orschemaNameparameter should explicitly warn about this insteadof only being covered in the README's general "mixed case" note.
Workaround
Setting
respectCase: trueexplicitly resolves it, as documented in the README.