0

This works fine;

<targets>
    <target name="database" xsi:type="Database"
            dbProvider="Npgsql.NpgsqlConnection, Npgsql"
            connectionString="User ID=postgres;Password=xxx;Host=192.xx;Port=5432;Database=xxx;">
      <!--Pooling=true;-->
      <commandText>
        insert into systemlogs(...;
      </commandText>

But when changed to table name as

"SystemLogs"

(same done in database as well) it throws exception; "couldnt find table name "systemlogs"

which make sense there isnt but why nlog dont realize updated table name?

Julian
  • 33,915
  • 22
  • 119
  • 174

2 Answers2

1

In PostgreSQL all quoted identifiers (e.g. table and column names) are case sensitive:

See: Are PostgreSQL column names case-sensitive?

So NLog can't find them is you use quotes and the wrong casing.

So don't use quotes or use the correct casing

Julian
  • 33,915
  • 22
  • 119
  • 174
  • It would be better to say that if you CREATed or ALTERed table name using quoted name them you need to use that name with quotes from then on in. If you did not quote the name then it gets folded to lower case and also when it is used without quotes. – Adrian Klaver Jun 18 '20 at 19:58
1

If you specified the table name as "SystemLogs" inside double quotes then you will need to use it that way also:

insert into "SystemLogs" ...

In Postgresql quoted identifiers retain the case they are quoted with and need to be referred to the same way. If you create as unquoted name SystemLogs then it will be folded to lower case. See below for more detail:

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Adrian Klaver
  • 15,886
  • 2
  • 17
  • 28