private static EmailTraceListener GetEmailTraceListener(TextFormatter formatter)
{
// Log messages to a log file.
// Use the formatter passed
// as well as the header and footer
// specified.
I am also very new to Logging block. according to my knowledge we can configure all the email settings in app.config/web.config as a Trace Lister. So no need to write any code related to email settings in c#. Once you use Logger.Write("....."). your string
in write method will be redirected to the Trace listener you configured in .config file. This trace listener could be email, database, windows event log...etc. Unfortunatly I could not get good material in web. I would also wait for reply for someone to get
clear picture on how to configure all these things.
Please Mark as Answer, if it answers you, also correct me if I'm wrong.
First of all you must execute the .sql file that will create the Logging database for you. It is available in the <Drive Letter>\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts\LoggingDatabase.sql
. Then you can now (1)add a Database trace listener in the LAB. (2) Configure a connection string in your DAAB section which points to the database that was created running the said script. (3) Configure the DatabaseInstance property of the database trace
listener and point it to the created connection string in step #2. (4) Add a trace listener reference to the desired category and point its reference to the database trace listener.
Source: Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
sandeep.cec
Member
23 Points
40 Posts
How to handle exception using Microsoft enterprise library
Feb 04, 2010 06:31 AM|LINK
How to log the exception or send out an email in website using Microsoft EnterPrise library Exception handling .
sandeep.cec
Member
23 Points
40 Posts
Re: How to handle exception using Microsoft enterprise library
Feb 04, 2010 12:02 PM|LINK
I Used below method : But unable to send mail..
private static EmailTraceListener GetEmailTraceListener(TextFormatter formatter)
{
// Log messages to a log file.
// Use the formatter passed
// as well as the header and footer
// specified.
EmailTraceListener mailListener =
new EmailTraceListener("abc@snlcorporate.com", "abc@gmail.com", "Admin", "<<ApplicationName>>", "smtp.gmail.com", xyz, formatter);
return mailListener;
}
duttavr
Contributor
4035 Points
1079 Posts
Re: How to handle exception using Microsoft enterprise library
Feb 07, 2010 07:09 PM|LINK
I am also very new to Logging block. according to my knowledge we can configure all the email settings in app.config/web.config as a Trace Lister. So no need to write any code related to email settings in c#. Once you use Logger.Write("....."). your string in write method will be redirected to the Trace listener you configured in .config file. This trace listener could be email, database, windows event log...etc. Unfortunatly I could not get good material in web. I would also wait for reply for someone to get clear picture on how to configure all these things.
Please Mark as Answer, if it answers you, also correct me if I'm wrong.
sandeep.cec
Member
23 Points
40 Posts
Re: How to handle exception using Microsoft enterprise library
Feb 08, 2010 04:53 AM|LINK
for log Entry in database follow below post steps :
http://entlib.codeplex.com/Thread/View.aspx?ThreadId=83105
First of all you must execute the .sql file that will create the Logging database for you. It is available in the <Drive Letter>\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts\LoggingDatabase.sql . Then you can now (1)add a Database trace listener in the LAB. (2) Configure a connection string in your DAAB section which points to the database that was created running the said script. (3) Configure the DatabaseInstance property of the database trace listener and point it to the created connection string in step #2. (4) Add a trace listener reference to the desired category and point its reference to the database trace listener.
Source: Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
duttavr
Contributor
4035 Points
1079 Posts
Re: How to handle exception using Microsoft enterprise library
Feb 09, 2010 06:42 AM|LINK
Hi Sandeep, His/My question was related to Email sending using Logging Listers.
Please Mark as Answer, if it answers you, also correct me if I'm wrong.