Serilog MSSQL Sink doesn't write logs to database

后端 未结 2 1321
傲寒
傲寒 2020-11-29 13:02

I have created a .Net class library (4.6.2) and created serilog implementation which is called by other interfaces such as console app. Now when I use File sink type, the lo

2条回答
  •  孤独总比滥情好
    2020-11-29 13:27

    In my case it was because my database user didn't have the necessary permissions to log to the database schema.table.

    I ended up doing something like the following:

    /* CREATE A NEW ROLE */
    CREATE ROLE db_logger
    
    /* GRANT SELECT, INSERT TO THE ROLE */
    GRANT SELECT, INSERT ON [Logging].[Logs] TO db_logger --Allows SeriLog to insert
    

    Curiously "WriteTo" needs the SELECT permissions but "AuditTo" does not. Both methods need the INSERT permission.

提交回复
热议问题