CAB +NLog

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

CAB +NLog

rccnh
We are using Microsoft's Composite Application Block and Smartclient Software Factory.
I am trying to add Nlog to our application - which from a programming aspect doesn't seem to be difficult. But when I configure the NLog output to go to a Console, it isn't happening. If the target is a file, it writes there with no problem. But to a console it just blows thru the code and nothing appears.
 Has anyone tried to use the console as a target with CAB? Maybe somehow it is preventing the presentation of the Console.
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

rccnh
A little follow up - it still isn't working and if I configure the target for a MessageBox, it doesn't work either.

The writing to a console is bothersome but not critical. The messagebox could be a big problem though if we decide to use NLog for consistency in presenting application fatal errors.
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

rccnh
In reply to this post by rccnh
More follow up - I added the parameters in the Nlog config file of throwExceptions="true" and to write its internal log file to a text file. No errors were thrown, and the text file written is not showing any errors. Lists loading targets, etc.  and stuff that looks "normal".
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

Jarek Kowalski
Administrator
Can you make a minimal example that exhibits the problem, zip all things together and post them here?
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

rccnh
CAB_NLOG.zip

Ok - zip file should be attached. This is all done with VS 2005 and NET 2.0.
I created a new application using the Smart Client Software Factory. That creates a "shell" (think of it as a MDI Parent) and other libraries. In one of the librairies, I created a "view". Simple user object with a button on it. In that same library, there is a ModuleController.cs. In that, I added the lines needed to show the view within the shell. I also added a reference to NLog there, and a line to write out to NLog. I have an NLog.config file in the bin/debug directory that has targets for a messagebox, console, and file (file is written a log.txt in a /log directory).
 Run the application, and the view should appear. But the messagebox and console do not open. However, the entry is written to  file.txt.
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

Jarek Kowalski
Administrator
To enable console, change your project output type to "Console Application" in Project Properties. Unfortunately NLog doesn't allocate console if it's not present, but this may be improved in future versions.

As for the MsgBox - looks like you found a bug. I'm working on it and will let you know when the fix is available.

NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: CAB +NLog

Jarek Kowalski
Administrator
Sorry, this is not a bug.  You have maxlevel="Trace" where it should be minlevel="Trace". maxlevel means "all levels lower than or equal to Trace"

As you're emiting your message on the "Debug" level, the message gets discarded.

NLog Blog