TalShyar
TalShyar

Reputation: 119

Recommendations for enabling basic logging for a small utility

I sometimes write small utilities. There are times when I need to output what is happening to a text. Currently, I am using stringbuilder to hold my text and then right before my app is done processing, it writes the stringbuilder out to a text file.

I recently came across NLog and I like what I see. My only problem is that when I send my utilities out, currently I just need to send out a single .exe file. However, if I use NLog, I have to also include the config file (saw a post where you could theoretically create the config file and use it programmatically) and the .dll file.

I would prefer to have some form of logging that would still allow me to send my utilities out as a single .exe file.

Any suggestions or recommendations?

Upvotes: 3

Views: 181

Answers (2)

TrueWill
TrueWill

Reputation: 25523

Example of configuring NLog in code:

https://stackoverflow.com/a/4317263/161457

Merging multiple assemblies:

ILMerge

Alternately you could create an installer.

Upvotes: 0

Alexei Levenkov
Alexei Levenkov

Reputation: 100527

Using default .Net tracing may be enough for your needs. Check out TextWriterTraceListener http://msdn.microsoft.com/en-us/library/system.diagnostics.textwritertracelistener.aspx which also includes sample of tracing to a file.

Debug.XXXX by default will be not available in Release buils, while Trace.XXXX are.

One can dynamically configure tracing levels if needed. See http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.aspx and tracing overview at http://msdn.microsoft.com/en-us/library/x5952w0c.aspx

Upvotes: 4

Related Questions