When I use %l or %L in my PatternLayout for debugging, I get the location of my extension static class and the line number in that file and not the location and line of the caller. Any of the standard logging methods produce correct results. Is there a way to get the extension methods to do this?
Part of my Log4NetExtensions.cs
namespace Dashboard
{
public static partial class Util
{
public static void SqlError(this ILog log, SqlException sqle)
{
if (log.IsDebugEnabled)
{
string[] names = Enum.GetNames(typeof(Dashboard.Models.Response.DashError.StandardErrors));
int idx = Array.IndexOf(names, sqle.Message);
if (idx > 0)
{
log.Debug(sqle.Message);
}
else
{
log.Error(sqle);
}
}
else
{
log.Error(sqle);
}
}
}
}
Edit: Per wageoghe's answer, I changed the log.Error() and log.Debug to this but it still prints Util and not the caller:
log.Logger.Log(typeof(Util), Level.Error, sqle.Message, sqle);