Variables in NLog.config

2,933 views
Skip to first unread message

Douglas Jones

unread,
Nov 21, 2013, 1:08:10 PM11/21/13
to nlog-...@googlegroups.com
Excuse what is probably a question based on ignorance but deadlines are short and I have run out of time to chase around anymore.

Since I have hunted up and down the web and poked through the documentation, I am hoping someone here can point me in the correct direction to find a list of what the various variables that are in the NLog.config file mean. ${longdate} and ${shortdate} and pretty self explanatory. I see ${basedir} used a lot, I just do not like dropping my log file in my Debug folder in my project with VS2012. There has to be: 1) More default variables; and 2) A list someplace as to what the definition is.

Also if someone could give me a hand I prefer my logs to go to the C:\ProgramData folder. I would normally use something like: C:\ProgramData\logs\AppName\Date & Time\AppNameDate& Time.txt

Replace AppName with the name of the app being logged
Replace Date & Time with  I am guessing ${longDate}

Thanks very much,
Doug

Kim Christensen

unread,
Nov 21, 2013, 7:43:31 PM11/21/13
to nlog-...@googlegroups.com

The best description of the available layout renderers is probably the wiki page at github, https://github.com/NLog/NLog/wiki/Layout-Renderers.
But beware that writing to ProgramData may require admin privileges.

Douglas Jones

unread,
Nov 22, 2013, 3:24:25 PM11/22/13
to nlog-...@googlegroups.com
Thanks! That helps a lot. Doesn't look like there is a variable for the root directory (C:\). So that one I will have to figure out. Can I use C:/ProgramData/ ?

Kim Christensen

unread,
Nov 26, 2013, 3:19:50 PM11/26/13
to nlog-...@googlegroups.com

There isn't a variable for that, but you should be able to type it in directly in the file target

Douglas Jones

unread,
Nov 26, 2013, 7:48:23 PM11/26/13
to nlog-...@googlegroups.com
Thanks! I will give that a go.

Douglas Jones

unread,
Nov 26, 2013, 9:00:11 PM11/26/13
to nlog-...@googlegroups.com
Kim,
I gave up on the common infrastructure stuff as it does not seem to work as well as I had hoped.

So, NLog documentation and tutorials indicate that one would want a logger per class. This is a reasonably large application using a combination of directories and other projects. I really only want everything to be logged into a single file and I am hoping that I do not have to create a logger in every class! Surely, I can create a statis logger in the App class the reference it everywhere else? Or is that going to give NLog a problem?

Thanks for the help!

Doug

Kim Christensen

unread,
Nov 27, 2013, 4:24:34 AM11/27/13
to nlog-...@googlegroups.com

That should be okay, and shouldn't cause any problems.

Reply all
Reply to author
Forward
0 new messages