Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:03:27+00:00 2026-06-04T14:03:27+00:00

When I take down the database that backs nlog, nothing gets get logged and

  • 0

When I take down the database that backs nlog, nothing gets get logged and it seems NLog swallows the problem. Is there any way to configure it to raise and exception or at least to log in a text file that logging failed?

Here is what my configuration looks like:

<?xml version="1.0" ?>
<nlog autoReload="true" throwExceptions="true" internalLogFile="${basedir}/App_Data/nlog.txt" internalLogLevel="Debug"
 internalLogToConsole="true">

 <targets>
 <!--Useful for debugging-->
 <target name="consolelog" type="ColoredConsole"
 layout="${date:format=HH\:mm\:ss}|${level}|${stacktrace}|${message}" />



 <target name="databaselog" type="Database">

 <dbProvider>System.Data.SqlClient</dbProvider>

 <!-- database connection parameters -->
 <!-- alternatively you could provide a single 'connectionstring' parameter -->
 <connectionString>Data Source=.\SQLEXPRESSZ;Initial Catalog=aspnetdb;Integrated Security=SSPI</connectionString>

 <commandText>
 insert into NLog_Error ([time_stamp],[level],[host],[type],[source],[logger],[message],[stacktrace],[allxml]) values(@time_stamp,@level,@host,@type,@source,@logger,@message,@stacktrace,@allxml);
 </commandText>

 <parameter name="@time_stamp" layout="${utc_date}" />
 <parameter name="@level" layout="${level}" />
 <parameter name="@host" layout="${machinename}" />
 <parameter name="@type" layout="${exception:format=type}" />
 <parameter name="@source" layout="${callsite:className=true:fileName=false:includeSourcePath=false:methodName=false}" />
 <parameter name="@logger" layout="${logger}" />
 <parameter name="@message" layout="${message}" />
 <parameter name="@stacktrace" layout="${exception:stacktrace}" />
 <parameter name="@allxml" layout="${web_variables}" />

 </target>

 </targets>

 <rules>

 <logger name="*" minlevel="Info" writeTo="databaselog" />
 </rules>

</nlog>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:03:28+00:00Added an answer on June 4, 2026 at 2:03 pm

    You can force Nlog to throw exception when sql server is not reached by following

    <nlog throwExceptions="true">
     ... your nlog config
    </nlog>
    

    More info here,

    http://nlog-project.org/2010/09/05/new-exception-handling-rules-in-nlog-2-0.html

    It’s a new feature in v2.0 so you need v2.0.

    It will not work in earlier versions.

    Also checkout following configuration info

    https://github.com/NLog/NLog/wiki/Logging-Troubleshooting

    which allows Nlog to log it’s own exceptions to a specified file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been contacted by a hacker saying there gonna take my site down
Need to take a SELECT drop down list options and find if any of
Rails 3 on Apache with Passenger: I need to take down Rails so that
I've noticed that google app engine seems to have a fair amount of downtime
I have databases which manage files. The reason that there are multiple is that
I started to use the database projects that are in Visual Studio to start
I'm currently working on a project that involves moving a database of documents for
I just realized that there is no best way to hide MySQL string connection
Imagine a database table that looks like this: create table [dbo].[user] ( id int
I am trying to write a php script that take a text file break

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.