Share nlog config with multiple projects and the proper threadsafe way to all write to the same log

1,259 views
Skip to first unread message

JSchwartz

unread,
Dec 13, 2012, 1:49:50 AM12/13/12
to nlog-...@googlegroups.com

My program consists of a single EXE and 6 DLLs (and of course everyone references everyone), I currently have a crude static logging class (Logger) which is in its own DLL (Logger.dll) which I add as a reference to each of my projects and use ... but instead of re-inventing the wheel I was looking to replace this with nLog.

Problem is I can't seem to figure out how all my projects can share the same nLog config file (I want everything logging to the SAME file and I do not want to define a config file per project).

1- is there a way to have a sinlge config file for all my projects?
2- is this safe to do? will nLog in each project accessing the same file not cause contention issues? does nLog already handle this correctly?

Or would it simply be best for me to wrap nLog in my static Logger.dll (odd to do but would work also) and keep doing things like I do today in my application?

Thanks,

Jason LaFlair

unread,
Dec 14, 2012, 9:56:45 AM12/14/12
to nlog-...@googlegroups.com
The NLog.config only needs to be 'stored' in the same path as the entry point.

If you want to 'share' the config - just add it to a common path - then add it to your project as a link (Add existing item -> there is a carrot on the Add button to "Add as Link".

Is that what you're hoping to do?

Jason.

JSchwartz

unread,
Dec 14, 2012, 11:54:57 PM12/14/12
to nlog-...@googlegroups.com
Do I need to "share" it?
My only goal is for all the components to log to the same file ...
Can I only have it declared at the EXE level? If so how do I ensure that all the DLLs log to the same file? Do they just all need to have the same LogManager.GetLogger(...)?
 
Even if I share it, then I will have many NLOG's all pointing to the same file with their own reference and their own config file ... is this the right way to do it?
Thanks,
Reply all
Reply to author
Forward
0 new messages