Saturday, 15 September 2012

c# - wrong file and line in log4net wrapper -



c# - wrong file and line in log4net wrapper -

i wrote log4net wrapper

public class log4netwrapper : ilogger { private readonly log4net.ilog logger; public log4netwrapper(string loggername) { logger = log4net.logmanager.getlogger(loggername); } public void debug(string message, params object[] values) { logger.debugformat(message, values); } public bool isdebugenabled {get { homecoming logger.isdebugenabled; } } ... }

the problem line , file when logging of wrapper , not actual location of message.

this design, if interested in line , file exception thrown in first place should log exception object or stacktrace member, if have configured log4net file appender show file , line message been written from, normal find wrapper, when logging exceptions , stacktrace find right content.

in our appenders have following, not show wrapper class name or file/line...

<log4net> <appender name="fileappender" type="log4net.appender.rollingfileappender"> <threshold value="all"/> <immediateflush>true</immediateflush> <lockingmodel type="log4net.appender.fileappender+minimallock"/> <encoding value="utf-8"/> <file value="d:\axis\rpp\logs\mylogfile.log" /> <appendtofile value="true"/> <rollingstyle value="date" /> <maxsizerollbackups value="30" /> <maximumfilesize value="25mb" /> <staticlogfilename value="true"/> <layout type="log4net.layout.patternlayout"> <conversionpattern value="[%property{log4net:hostname}] - %username%newline%utcdate - %-5level - %message%newline"/> </layout> </appender> <root> <priority value="all"/> <appender-ref ref="fileappender"/> </root>

c# log4net wrapper

No comments:

Post a Comment