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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:50:01+00:00 2026-06-14T16:50:01+00:00

I have a problem reading the configuration file (NLog.config) from my class library project

  • 0

I have a problem reading the configuration file (NLog.config) from my class library project when I call it from my ASP.NET MVC4 project.

I tested my code using an Unit Test Project and reads the configuration file properly and makes logging correctly on the file that I specified on the NLog.config, so the NLog.config is correctly defined.

I also set “Copy always” at Copy to Output Directory settings, just like the tutorial says.

The problem is that when I called the class library project, from my ASP project, I realized that wasn’t making any kind of log, and when I debugged, I saw that It wasn’t picking the configuration from NLog.config, and for that reason, my project didn’t know when and where to log.

When I looked into “ASP project folder”/bin, there are the files from NLog: NLog.dll, NLog.config and NLog.xml, so in theory, the ASP project, can access without problem to the NLog files.

I read the tutorial from NLog but I can’t figured out the solution. Just can´t understand why from my test project works properly but when I make the same call from my ASP project just don’t work.

This is my configuration file for NLog.

<?xml version="1.0" encoding="utf-8" ?>
<nlog throwExceptions="true" 
  xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<targets>
  <target name="logfile" xsi:type="File" fileName="C:\logfile.txt" layout="${callsite:fileName=true} - ${longdate} - ${level:uppercase=true} - ${logger} - ${message}"/>
</targets>

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

And within my classes, I create the logger this way:

private static Logger logger = LogManager.GetCurrentClassLogger();

Can anybody help me with this problem?

  • 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-14T16:50:02+00:00Added an answer on June 14, 2026 at 4:50 pm

    I figured out the solution.

    Seems like with the copy to output directory setting, isn’t enough with asp.net-mvc4.

    Copy to output directory

    I had to manually copy the NLog.config into the asp project itself inside the Solution explorer.

    Project explorer http://imageshack.us/a/img849/2460/sol1o.png

    In this example, I copied the NLog.config from LoggingLibrary into LogWebApp project and It works well.

    Greetings!

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

Sidebar

Related Questions

The problem I have is reading in multiple lines of integers from a file
I have a problem reading a txt file to insert in the mysql db
Android 2.1 update 1 Eclipse 3.5 I have a problem reading data from my
I have some problem with reading from sqlite3 database. -(void) readMessengesFromDatabase { sqlite3 *database;
In my assignment i have a problem with reading a file. See the following
My problem involves checking if I have a valid database connection before reading from
I have a problem: change setting in user control's configuration file has no effect.
I have a stupid java logging problem: I'm loading the logging configuration from my
I have three classes, one class loads in a configuration file into memory for
I'm working on reading a path from a simple configuration file and store it

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.