Hy,
I have a static function which calls logg.info or logger.debug and so on,
depending of where I call it. How can I save into log file the class and
line from where I called the function. Logger writes the class/line from the
function I created not from the call made.
Example:
In a static class
public static void appendLog(string messageType, string message, Exception
exc)
{
messageType = messageType.ToUpper();
switch(messageType)
{
case "INFO":
{
if (exc == null)
{
MainForm.logger.Info(message);
}
else
{
MainForm.logger.Info(message, exc);
}
break;
}
case "DEBUG":
{
if (exc == null)
{
MainForm.logger.Debug(message);
}
else
{
MainForm.logger.Debug(message, exc);
}
break;
}
case "ERROR":
{
if (exc == null)
{
MainForm.logger.Error(message);
}
else
{
MainForm.logger.Error(message, exc);
}
break;
}
case "FATAL":
{
if (exc == null)
{
MainForm.logger.Fatal(message);
}
else
{
MainForm.logger.Fatal(message, exc);
}
break;
}
case "WARNING":
{
if (exc == null)
{
MainForm.logger.Warn(message);
}
else
{
MainForm.logger.Warn(message, exc);
}
break;
}
default:
break;
}
}
from another class I call:
appendLog("error","Exception thrown", exc);
the logger saves class/line from the static class and I want it to save the
assembly info from the calling class.
Can it be done?
(code is an example. not final )
Thanks
