MSSqlServer sink only logs when LoggingLevelSwitch is Information or lowerHow to solve producer/consumer race condition with BlockingCollection<>Logging properties to Serilog Email SinkSerilog MSSqlServer sink not writing to tableSerilog .write(logevent) using mssqlserver sinkserilog-sinks-mssqlserver: Exclude column in xml Config fileConfigure Column Options for Serilog Sinks MsSqlServer in AppSettings.jsonOutputting JSON with the MSSqlServer Serilog sinkCurrent log file names for the file sinks in Serilog?Logging to email sink with Serilogserilog to log only debug, error and warning logs but not information

What is a "tittering order"?

Performance of loop vs expansion

Isn't "Dave's protocol" good if only the database, and not the code, is leaked?

Is it possible to spoof an IP address to an exact number?

Phrase origin: "You ain't got to go home but you got to get out of here."

Auto replacement of characters

Will greasing clutch parts make it softer

How come having a Deathly Hallow is not a big deal?

What is the difference between a historical drama and a period drama?

What could a Medieval society do with excess animal blood?

What does the ash content of broken wheat really mean?

What is the right way to query an I2C device from an interrupt service routine?

What instances can be solved today by modern solvers (pure LP)?

Does this circuit have marginal voltage level problem?

Use real text instead of lipsum in moderncv quote alignment

What can a novel do that film and TV cannot?

Why would a propellor have blades of different lengths?

gzip compress a local folder and extract it to remote server

Olive oil in Japanese cooking

How to widen the page

Go function to test whether a file exists

Who pays for increased security measures on flights to the US?

Do I need to be legally qualified to install a Hive smart thermostat?

Why did my leaking pool light trip the circuit breaker, but not the GFCI?



MSSqlServer sink only logs when LoggingLevelSwitch is Information or lower


How to solve producer/consumer race condition with BlockingCollection<>Logging properties to Serilog Email SinkSerilog MSSqlServer sink not writing to tableSerilog .write(logevent) using mssqlserver sinkserilog-sinks-mssqlserver: Exclude column in xml Config fileConfigure Column Options for Serilog Sinks MsSqlServer in AppSettings.jsonOutputting JSON with the MSSqlServer Serilog sinkCurrent log file names for the file sinks in Serilog?Logging to email sink with Serilogserilog to log only debug, error and warning logs but not information






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am writing a simple training console app that triggers a fatal error when a user enters just numbers (on purpose). I have a main logger made up of 3 other loggers: 1 database, 1 file, 1 event. I change the file and database verbosity dynamically with separate LoggingLevelSwitches. The File switch is working as expected. The MSSqlServer correctly sets the switch, but I can't get anything to actually log unless the switch is set to Information or lower. Then all of the Warning, Error, Fatal entries that were not logged before are correctly entered into the database.



How do I get the sqlserver sink to correctly log entries when the switch is at a higher verbosity level? Everything works fine at lower verbosities, but I don't want to fill up the db with info unless needed. There is no issue with File or Event loggers



*I have a dispose object that closes and flushes the log



Thanks for any help!



creation of db logger



return new LoggerConfiguration()
.MinimumLevel.ControlledBy(gDBLevel)
.WriteTo.Async(a => a.MSSqlServer(connectionString: pInitObj.DBConnectionString
, tableName: pInitObj.DBTableName
, batchPostingLimit: 50
, period: TimeSpan.FromMilliseconds(10)
, formatProvider: null
, autoCreateSqlTable: false
, columnOptions: tmpOptions
, schemaName: pInitObj.DBSchema))
.CreateLogger();


creation of complete logger



return new LoggerConfiguration()
.Enrich.WithProperty(Constants.DefaultDataTags.AppName.ToString(), pInitObj.LogName.ToString())
.Enrich.With<EventID>()
.Enrich.With<HttpUserName>()
.Enrich.With<HttpUserIsAuthenticated>()
.Enrich.FromLogContext()
.Enrich.WithMvcActionName()
.Enrich.WithMvcControllerName()
.Enrich.WithHttpRequestClientHostIP()
.Enrich.WithHttpRequestUrl()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestType()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestUserAgent()
.Enrich.WithEnvironmentUserName()
.WriteTo.Logger(getEventLogger(pInitObj))
.WriteTo.Logger(getFileLogger(pInitObj))
.WriteTo.Logger(getDBLogger(pInitObj))


.CreateLogger();









share|improve this question






















  • I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

    – workingmantypething
    Mar 25 at 18:51

















0















I am writing a simple training console app that triggers a fatal error when a user enters just numbers (on purpose). I have a main logger made up of 3 other loggers: 1 database, 1 file, 1 event. I change the file and database verbosity dynamically with separate LoggingLevelSwitches. The File switch is working as expected. The MSSqlServer correctly sets the switch, but I can't get anything to actually log unless the switch is set to Information or lower. Then all of the Warning, Error, Fatal entries that were not logged before are correctly entered into the database.



How do I get the sqlserver sink to correctly log entries when the switch is at a higher verbosity level? Everything works fine at lower verbosities, but I don't want to fill up the db with info unless needed. There is no issue with File or Event loggers



*I have a dispose object that closes and flushes the log



Thanks for any help!



creation of db logger



return new LoggerConfiguration()
.MinimumLevel.ControlledBy(gDBLevel)
.WriteTo.Async(a => a.MSSqlServer(connectionString: pInitObj.DBConnectionString
, tableName: pInitObj.DBTableName
, batchPostingLimit: 50
, period: TimeSpan.FromMilliseconds(10)
, formatProvider: null
, autoCreateSqlTable: false
, columnOptions: tmpOptions
, schemaName: pInitObj.DBSchema))
.CreateLogger();


creation of complete logger



return new LoggerConfiguration()
.Enrich.WithProperty(Constants.DefaultDataTags.AppName.ToString(), pInitObj.LogName.ToString())
.Enrich.With<EventID>()
.Enrich.With<HttpUserName>()
.Enrich.With<HttpUserIsAuthenticated>()
.Enrich.FromLogContext()
.Enrich.WithMvcActionName()
.Enrich.WithMvcControllerName()
.Enrich.WithHttpRequestClientHostIP()
.Enrich.WithHttpRequestUrl()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestType()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestUserAgent()
.Enrich.WithEnvironmentUserName()
.WriteTo.Logger(getEventLogger(pInitObj))
.WriteTo.Logger(getFileLogger(pInitObj))
.WriteTo.Logger(getDBLogger(pInitObj))


.CreateLogger();









share|improve this question






















  • I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

    – workingmantypething
    Mar 25 at 18:51













0












0








0








I am writing a simple training console app that triggers a fatal error when a user enters just numbers (on purpose). I have a main logger made up of 3 other loggers: 1 database, 1 file, 1 event. I change the file and database verbosity dynamically with separate LoggingLevelSwitches. The File switch is working as expected. The MSSqlServer correctly sets the switch, but I can't get anything to actually log unless the switch is set to Information or lower. Then all of the Warning, Error, Fatal entries that were not logged before are correctly entered into the database.



How do I get the sqlserver sink to correctly log entries when the switch is at a higher verbosity level? Everything works fine at lower verbosities, but I don't want to fill up the db with info unless needed. There is no issue with File or Event loggers



*I have a dispose object that closes and flushes the log



Thanks for any help!



creation of db logger



return new LoggerConfiguration()
.MinimumLevel.ControlledBy(gDBLevel)
.WriteTo.Async(a => a.MSSqlServer(connectionString: pInitObj.DBConnectionString
, tableName: pInitObj.DBTableName
, batchPostingLimit: 50
, period: TimeSpan.FromMilliseconds(10)
, formatProvider: null
, autoCreateSqlTable: false
, columnOptions: tmpOptions
, schemaName: pInitObj.DBSchema))
.CreateLogger();


creation of complete logger



return new LoggerConfiguration()
.Enrich.WithProperty(Constants.DefaultDataTags.AppName.ToString(), pInitObj.LogName.ToString())
.Enrich.With<EventID>()
.Enrich.With<HttpUserName>()
.Enrich.With<HttpUserIsAuthenticated>()
.Enrich.FromLogContext()
.Enrich.WithMvcActionName()
.Enrich.WithMvcControllerName()
.Enrich.WithHttpRequestClientHostIP()
.Enrich.WithHttpRequestUrl()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestType()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestUserAgent()
.Enrich.WithEnvironmentUserName()
.WriteTo.Logger(getEventLogger(pInitObj))
.WriteTo.Logger(getFileLogger(pInitObj))
.WriteTo.Logger(getDBLogger(pInitObj))


.CreateLogger();









share|improve this question














I am writing a simple training console app that triggers a fatal error when a user enters just numbers (on purpose). I have a main logger made up of 3 other loggers: 1 database, 1 file, 1 event. I change the file and database verbosity dynamically with separate LoggingLevelSwitches. The File switch is working as expected. The MSSqlServer correctly sets the switch, but I can't get anything to actually log unless the switch is set to Information or lower. Then all of the Warning, Error, Fatal entries that were not logged before are correctly entered into the database.



How do I get the sqlserver sink to correctly log entries when the switch is at a higher verbosity level? Everything works fine at lower verbosities, but I don't want to fill up the db with info unless needed. There is no issue with File or Event loggers



*I have a dispose object that closes and flushes the log



Thanks for any help!



creation of db logger



return new LoggerConfiguration()
.MinimumLevel.ControlledBy(gDBLevel)
.WriteTo.Async(a => a.MSSqlServer(connectionString: pInitObj.DBConnectionString
, tableName: pInitObj.DBTableName
, batchPostingLimit: 50
, period: TimeSpan.FromMilliseconds(10)
, formatProvider: null
, autoCreateSqlTable: false
, columnOptions: tmpOptions
, schemaName: pInitObj.DBSchema))
.CreateLogger();


creation of complete logger



return new LoggerConfiguration()
.Enrich.WithProperty(Constants.DefaultDataTags.AppName.ToString(), pInitObj.LogName.ToString())
.Enrich.With<EventID>()
.Enrich.With<HttpUserName>()
.Enrich.With<HttpUserIsAuthenticated>()
.Enrich.FromLogContext()
.Enrich.WithMvcActionName()
.Enrich.WithMvcControllerName()
.Enrich.WithHttpRequestClientHostIP()
.Enrich.WithHttpRequestUrl()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestType()
.Enrich.WithHttpSessionId()
.Enrich.WithHttpRequestUserAgent()
.Enrich.WithEnvironmentUserName()
.WriteTo.Logger(getEventLogger(pInitObj))
.WriteTo.Logger(getFileLogger(pInitObj))
.WriteTo.Logger(getDBLogger(pInitObj))


.CreateLogger();






c# serilog






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 17:46









workingmantypethingworkingmantypething

1




1












  • I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

    – workingmantypething
    Mar 25 at 18:51

















  • I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

    – workingmantypething
    Mar 25 at 18:51
















I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

– workingmantypething
Mar 25 at 18:51





I was incorrect about the File being fine. Apparently this is an issue anytime a minimum log level is set above information. This includes directly in the logger with restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error, for example.

– workingmantypething
Mar 25 at 18:51












1 Answer
1






active

oldest

votes


















0














It appears that the issue had to do with timing. Since all of the loggers were async, the program was closing too fast for the logs to get written on flush. I am pretty sure that the main program thread closes which collapses all of the spawned child threads on the logger before the logger has had time to complete the async processes.



Adding a half a second threading pause on the dispose after the flush call seems to have worked. Might have to bump it up to a second later on but whatevs.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343744%2fmssqlserver-sink-only-logs-when-logginglevelswitch-is-information-or-lower%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It appears that the issue had to do with timing. Since all of the loggers were async, the program was closing too fast for the logs to get written on flush. I am pretty sure that the main program thread closes which collapses all of the spawned child threads on the logger before the logger has had time to complete the async processes.



    Adding a half a second threading pause on the dispose after the flush call seems to have worked. Might have to bump it up to a second later on but whatevs.






    share|improve this answer



























      0














      It appears that the issue had to do with timing. Since all of the loggers were async, the program was closing too fast for the logs to get written on flush. I am pretty sure that the main program thread closes which collapses all of the spawned child threads on the logger before the logger has had time to complete the async processes.



      Adding a half a second threading pause on the dispose after the flush call seems to have worked. Might have to bump it up to a second later on but whatevs.






      share|improve this answer

























        0












        0








        0







        It appears that the issue had to do with timing. Since all of the loggers were async, the program was closing too fast for the logs to get written on flush. I am pretty sure that the main program thread closes which collapses all of the spawned child threads on the logger before the logger has had time to complete the async processes.



        Adding a half a second threading pause on the dispose after the flush call seems to have worked. Might have to bump it up to a second later on but whatevs.






        share|improve this answer













        It appears that the issue had to do with timing. Since all of the loggers were async, the program was closing too fast for the logs to get written on flush. I am pretty sure that the main program thread closes which collapses all of the spawned child threads on the logger before the logger has had time to complete the async processes.



        Adding a half a second threading pause on the dispose after the flush call seems to have worked. Might have to bump it up to a second later on but whatevs.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 1 at 18:57









        workingmantypethingworkingmantypething

        1




        1
















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343744%2fmssqlserver-sink-only-logs-when-logginglevelswitch-is-information-or-lower%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현