Profile Picture

Using NLog

Posted By gregoryj 8 Years Ago
Message
Posted Thursday November 12 2009
Does anyone have a quick example they could post of how to use NLog. I can't seem to get it to write to a file. Not sure its picking up my config.



private static Logger logger = LogManager.GetLogger("MySymbolScript");

public override void NewBar() {
logger.Trace("Testing");
}


Posted Tuesday January 24 2012
Hey I'm having the same problem. I tested it on a non RightEdge based project and it works great. However, it does not send logs from inside the system code. I added two screen shots to show the situation.

Can somebody that uses NLog help out please?
Thanks.

This project sends log


This RE project does not.


EDIT: I just noticed I made one static and the other not. For the record, I tried both way and it doesnt make a difference, no logs from the system.

Edited: Tuesday January 24 2012 by parliament718
Posted Wednesday January 25 2012
See this page about where NLog looks for the configuration file:

NLog Configuration file

So for a file named NLog.config to work, you'd have to copy it to RightEdge's application directory. However, I suspect that because RightEdge runs trading systems in a different AppDomain, NLog wouldn't be able to know what the application directory is.

So probably what you should do is name the config file nlog.dll.nlog and have it copied to the same folder as the nlog DLL.

Thanks,
Daniel
phg
Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)Supreme Being (44,795 reputation)
Posted Thursday January 26 2012
I'm not sure this will help, but note the comment about "Copy always" in the tutorial, which seems to get at the point Daniel is making:
http://nlog-project.org/wiki/Tutorial 

-Pete

See also Yahoo group about applying RE.

Posted Thursday January 26 2012
Thanks for your replies.
I tried renaming the file to Nlog.dll.nlog.config but this didn't solve.
I also tried setting throwException="true" in the configuration file and then trying to catch it and output it the the System Output but it doesn't seem to be throwing an exception. Tried outputting the exception to a file just in case (by setting internalLogFile=="C:\...\file.txt" along with throwException="true") ...file remains empty.

For the record, I'm trying to output to Sentinel as seen in my config file below but this is not the problem because there are still no logs when I tried to output them to a file instead. This configuration file also works fine and writes to Sentinel in my non-RE control project.

Any more idea what this could be?

Posted Friday January 27 2012
I'm not sure the file is named correctly. It looks like you need to take the ".config" off the file name of your nlog configuration file.

If that doesn't work, I suggest using Process Monitor to see what files and in which path it is looking for the configuration. Process Monitor will show you all file accesses (and other things) that a program does. It is a ton of information so you'll want to filter it just to stuff with nlog in the name.

Thanks,
Daniel
Posted Friday January 27 2012
After using Process Monitor for most of the morning and trying countless combinations of config file names .ini, .xml, .config, nlog.dll.nlog,etc and moving them around all over the RightEdge directories I finally found the solution. Create the configuration file as follows. There's no need to create additional configuration files in subsequent projects. Just add a reference to NLog.dll and use.

C:\Program Files(x86)\Yye Software\RightEdge 2010\RightEdge.exe.nlog

Thanks for your help, Daniel.

Edited: Friday January 27 2012 by parliament718


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems