Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NLog llog to custom directory

Posted on 2011-02-17
4
Medium Priority
?
677 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
  • 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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 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