Sending Mail using NLOG to log error messages or Information messages in .net windows applications

702 views
Skip to first unread message

Kamal

unread,
Apr 24, 2013, 4:44:36 AM4/24/13
to nlog-...@googlegroups.com

Hello 

I am using NLOG tool in .NET 4.0 windows applications  to log my errors or information messages.I would like to send logging messages as mail. When i am calling all the log levels Debug(), Trace(), Info(), Fatal() etc, the mail is sent every time for each and every log level

I am trying to configure a smtp to send mail in the NLOG file that I have. The problem is that I have looked all over the internet and cannot find how to send an email when an error occurs with all the other log information included such as info, debug, error, fatal. Only when the application ends (NOT every time an ERROR occurs).

So I only want to receive this email when: The application ends + With all the log information (DEBUG, INFO, ERROR, FATAL) + Only if an ERROR has occurred not every time when i call the log levels

Elaborating some more this is because of the way I handle my exceptions in c sharp, with multiple level handling all over the place and so if an error occurs no matter how many times I only want to receive one email. Also I do not want to use multiple logs, but rather just one in root.

Thanks.

Kamal

Kim Christensen

unread,
Apr 24, 2013, 3:22:42 PM4/24/13
to nlog-...@googlegroups.com

There are currently no way to buffer log events, the way you want to. But nlog fully support automatic flushing the logs when the application exits, which is the default behavior. The feature could be created by developing a custom target. I can see the use case and may take a look at developing it when I have the time.

Kamal

unread,
Apr 25, 2013, 12:50:24 AM4/25/13
to nlog-...@googlegroups.com

Hi,

I have developed a windows application for our company. The application is ready for release. Now, we need to include debug and trace logging for all our code and error logging when any runtime exceptions arise on customer's PC. We need our application to write regular trace logs to customer's PC and whenever a runtime error occurs on customer's PC, the application should send all required logs to our company's email address.

I explored regarding trace logging tools for .Net and found a list of tools in the link http://www.dotnetlogging.com

With all the tools and libraries mentioned in this link, we should write our own trace using the methods in these libraries. I came to know about a tool VBWatch which is used for VB6 applications. This tool automatically writes all trace code for all the methods while building the application. So, our exe will be compiled with all this trace code. We need not write the trace code on our own. Whenever a runtime exception occurs on customer's PC, this VB Watch's dll/ocx, compresses all the log files along with error log and sends an email to the given email id.

So, we want to use a trace logging application similar to this VB Watch which automatically writes all the trace code. So that this reduces writing the trace on our own for all methods.

Please suggest if there is any tool similar to VB Watch for a .Net windows application.

Thanks in Advance!

Reply all
Reply to author
Forward
0 new messages