My application has following structure,
MyApp - C# Console Application
ClsMessage - C# Class Library
ClsLog - C# Class Library
I am calling ClsMessage class from MyApp to display message. ClsMessage checks
If application type is Windows then it display message box.
If application type is console then ClsMessage class calls ClsLog class to write message into log file. I am using log4Net for generating log. I want to trap error if log4Net is not configured properly.
When ClsMessage class calls ClsLog class, in ClsLog constructor I am using the following command to confiture the log4Net.
log4net.Config.XmlConfigurator.Configure();
If I did't properly confitured log4Net in App.config file, above line generate an error and display that error in console. But I want to trap that error and log that error in event log.
I am using the following code in ClsLog class constructor.
static Log()
{
try
{
log4net.Config.XmlConfigurator.Configure();
}
catch (Exception ex)
{
throw ex;
}
}
The above constructor can't catch the exception.