Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

NLog llog to custom directory

Posted on 2011-02-17
4
Medium Priority
?
674 Views
Last Modified: 2013-12-17
Hello,

I have started using NLog logging library.(currently logging to txt file)
<target> has a config like:
fileName="${basedir}/logs/logfile.txt"  

I want to log to, say D:\logfile.txt  

How can i do that ?
This seems simple but  i have failed to do it.
Thanks.
0
Comment
Question by:parabellum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
mkobrin earned 1500 total points
ID: 34915061
string path = "";
DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo driveInfo in drives)
            {
                if (driveInfo.DriveType == DriveType.Fixed)
                {
                    if (driveInfo.Name.ToUpper() == "D")
                        path = "D:\\YourDirectoryName";
                    break;
                }
            }
            if (!Directory.Exists(path ))
            {
                Directory.CreateDirectory(path );
            }
filename = path + "\\yourFilename";
0
 

Author Comment

by:parabellum
ID: 34916223
Well there is a misunderstanding.
I want to do it in the NLog config file.
0
 

Author Comment

by:parabellum
ID: 34916732
Nevermind i have solved it.  There was one extra '$' char  that caused problems.
0
 

Author Closing Comment

by:parabellum
ID: 34916742
Not quite the solution i wanted. But thanks for your time.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question