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

  • SEARCH
  • Home
  • 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 8393505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:48:29+00:00 2026-06-09T19:48:29+00:00

Using Nlog and a Database target, is there a way to set the connection

  • 0

Using Nlog and a Database target, is there a way to set the connection information at runtime?

  • 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-09T19:48:30+00:00Added an answer on June 9, 2026 at 7:48 pm

    I remember some colleague of mine doing something similar. He found this answer: http://nlog-forum.1685105.n2.nabble.com/DDL-for-Database-Table-How-to-set-Connection-String-Programmatically-td5241103.html that was working perfectly fine.

    From the link above

    The easiest way of overriding connection string is through the use of
    GDC:

    <target name="db" type="Database" connectionString="${gdc:myConnectionstring}" ... />
    

    Now in your code you can simply do:

    GDC.Set("myConnectionString", "Server=.;database=.....");
    

    You can also modify the target:

    var config = LogManager.Configuration;
    var dbTarget = (DatabaseTarget)config.FindTargetByName("db");
    dbTarget.ConnectionString = "server=.;...";
    LogManager.ReconfigExistingLoggers();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NLog to log to file. Is there a way to configure it
I am trying to integrate NLog into our application which is C# based using
Using SQL Server 2008 R2 we are looking for a way to select the
We are currently using NLog for logging (which was an arbitrary choice made some
I am using NLog and I want to log to RichTextBox and File at
I have a requirement to log to different log file using Nlog based different
I have the following target in my nlog.config : <target name=n1 xsi:type=Network address=tcp://localhost:4001/> but
I am using C# and Visual Studio 2010. When I use OutputDebugString to write debug information,
I am using NLog to provide all my logging, do you know if it
I'm using NLog as my logger, however I cant seem to find an Ilogger

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.