Solved

NLog llog to custom directory

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now