Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jake williamson 207 posts 873 karma points
    Jan 30, 2020 @ 00:54
    jake williamson
    0

    umbraco 8 serilog sql server database log

    hey out there,

    has anyone managed to set up serilog to write to a sql server database?

    i've tried... but to no avail...

    this is what i've done so far:

    1 - installed the Serilog.Sinks.MSSqlServer (https://github.com/serilog/serilog-sinks-mssqlserver) package via nuget.

    2 - updated the /config/serilog.user.config file with the following:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <appSettings>
    
            <!-- Controls log levels for all user-defined child sub-logger sinks configured here (Set this higher than child sinks defined here) -->
            <!-- VALID Values: Verbose, Debug, Information, Warning, Error, Fatal -->
            <add key="serilog:minimum-level" value="Debug" />
    
            <!-- All logs defined via user.config will contain this property (won't be in main Umbraco logs) -->
            <add key="serilog:enrich:with-property:websiteName" value="My Site" />
    
            <!-- Write to a user log file -->
            <add key="serilog:using:File" value="Serilog.Sinks.File" />
            <add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\MyLogs.%MACHINENAME%.json" />
            <add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
            <add key="serilog:write-to:File.retainedFileCountLimit" value="" />
            <!-- Number of log files to keep (or remove value to keep all files) -->
            <add key="serilog:write-to:File.rollingInterval" value="Day" />
            <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
    
            <add key="serilog:using:MSSqlServer" value="Serilog.Sinks.MSSqlServer" />
            <add key="serilog:write-to:MSSqlServer.connectionString" value="Server=localhost\MyServer;Database=MyDatabase;User Id=MyUserId;Password=MyPassword;"/>
            <add key="serilog.write-to:MSSqlServer.tableName" value="MyLogs" />
            <add key="serilog.write-to:MSSqlServer.autoCreateSqlTable" value="true" />
        </appSettings>
    </configuration>
    

    3 - what's happening? or not happening... the file log is working just fine. but the database table never gets created (<add key="serilog.write-to:MSSqlServer.autoCreateSqlTable" value="true" />).

    i've tried manually creating the database table but even then, nothing actually gets written to the table.

    has anyone managed to get this working?!

    cheers,

    jake

Please Sign in or register to post replies

Write your reply to:

Draft