Solved

NLog llog to custom directory

Posted on 2011-02-17
4
670 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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