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 3931828
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:23:24+00:00 2026-05-19T23:23:24+00:00

I have been assigned a project with a lot of poorly written code that

  • 0

I have been assigned a project with a lot of poorly written code that is based around SharePoint.

It consists of about 15 subprojects, some of them being windows services, some web services, some web applications running inside of SharePoint, some being webparts and even console applications. They all run on the same server and call each other.

There are already many issues in production but they are hard to trace down.
The original developer must have been a fan of either Salinger or Pokémon series judging by his tireless effort to catch all exceptions. Unfortunately, none of them get reported or logged, ever.

My current task is to introduce logging into the whole project so I could find now-invisible exceptions, follow tangled recurring calls and have some stack traces at least. I decided to go with NLog, seeing it’s active and cool, as opposed to log4net which is perfectly fine but somewhat not as fancy to my taste.

Because the components are tightly coupled, I want to centralize logging in one file so related errors don’t get scattered across the hard drive. Therefore, I am looking to have two or three different log files with five or more projects writing to each of them more or less simultaneously.

What is the best way to configure NLog to centralize logging? Should I have a config file for each project, or should related projects share them? Where should I put config file to log from SharePoint webparts? Am I going to face any permission issues?

I’m using SharePoint 2007.

  • 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-05-19T23:23:24+00:00Added an answer on May 19, 2026 at 11:23 pm

    The easiest way to centralize is probably to simply log to a database, one benefit being that multiple applications and write to the database easier than to the same log file. For each application, configure NLog to log to the Database target, using the same Database target configuration parameters for each. Your NLog.config file might look something like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <!-- 
      This file needs to be put in the application directory. Make sure to set 
      'Copy to Output Directory' option in Visual Studio.
      -->
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          autoReload="true" 
          internalLogLevel="Debug"
          internalLogFile="nlog_log.log">
    
    
      <targets async="true">
        <target name="sqlexpress" xsi:type="Database">
          <connectionString>
            Data Source=.\SQLEXPRESS;Initial Catalog=LoggingDB;Integrated Security=True;
          </connectionString>
          <commandText>
            insert into LogTable(DateTime,Logger,LogLevel,Message,ProcessId,ManagedThreadId) values (@DateTime,@Logger,@LogLevel,@Message,@ProcessId,@ManagedThreadId);
          </commandText>
          <parameter name="@DateTime" layout="${date:format=yyyy\-MM\-dd HH\:mm\:ss.fff}"/>
          <parameter name="@Logger" layout="${logger}"/>
          <parameter name="@LogLevel" layout="${level}"/>
          <parameter name="@Message" layout="${message}"/>
        </target>
    
        </target>
      </targets>
      <rules>
        <logger name="*" minlevel="Trace" writeTo="sqlexpress" />
      </rules>
    </nlog>
    

    You could certainly log to files in addition to (or instead of) logging to a database.

    I am not familiar with doing this from SharePoint, so I can’t comment on any configuration or permission issues that you might run into there.

    Here is a link I found where there is a discussion of getting NLog to work in a SharePoint environment:

    http://nlog-forum.1685105.n2.nabble.com/Is-anyone-using-NLog-with-SharePoint-td2171451.html

    That link appears to put you at the top of the NLog forum instead of the specific post. Search for this text in the forum “Is anyone using NLog with SharePoint” and you should find the right post.

    Good luck!

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

Sidebar

Related Questions

No related questions found

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.