我在基于Windows的.net应用程序中使用log4net功能,该应用程序与不同的第三方com dll进行交互。所以我可以看到日志文件获取日志,其中包含我们为日志记录编写的许多其他信息。 所以我只想知道我错过了任何配置,以便它只记录我们打算记录的那些信息。
细节
application : c# windows based 3.5 .net framework log4net version: 1.2
样品
2013-11-26 05:16:11,481 [15] INFO - TKS.DataDriver.DataDriver - LoadWorkBook : start LoadWorkBook operation
2013-11-26 05:16:13,653 [15] INFO - TKS.DataDriver.MsExcel.Common - inside method IsFileLocked
2013-11-26 05:16:19,028 [15] INFO - TKS.DataDriver.DataDriver - MergeTestCaseEntities : Merging all Test Case Entities.
2013-11-26 05:16:19,028 [15] INFO - TKS.DataDriver.DataDriver - LoadWorkBook : monitoringFlag: False MonitorQTPstatusOnOff: ON
2013-11-26 05:16:19,028 [15] INFO - TKS.DataDriver.DataDriver - LoadWorkBook : Asyncronus call for status check of the QTP.
2013-11-26 05:16:19,028 [15] INFO - TKS.DataDriver.DataDriver - DataLoadTestSet : DataLoad method call completed and result is : True
2013-11-26 05:16:19,028 [15] INFO - LogCatReplay - CProxy_IQTFuncLibMgrEvents::FireHelper Start. DispID = 4 Func=CProxy_IQTFuncLibMgrEvents<class CQTFuncLibMgr>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qtfunclibmgrcp.h Line=16 ThreadID=4636
2013-11-26 05:16:19,028 [15] INFO - LogCatReplay - UnitExecutionEngine: CProxy_IQTASUnitExecutionEngineEvents::FireHelper Start. DispID = 7 Func=CProxy_IQTASUnitExecutionEngineEvents<class CQTASUnitExecutionEngine>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qtasunitexecutionenginecp.h Line=15 ThreadID=4636
2013-11-26 05:16:19,028 [15] INFO - LogCatReplay - UnitExecutionEngine: CProxy_IQTASUnitExecutionEngineEvents::FireHelper End Func=CProxy_IQTASUnitExecutionEngineEvents<class CQTASUnitExecutionEngine>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qtasunitexecutionenginecp.h Line=39 ThreadID=4636
2013-11-26 05:16:19,043 [16] INFO - TKS.DataDriver.DataDriver - MonitorQTPstatus kick ON Now.
2013-11-26 05:16:19,059 [1] INFO - HP.QTP.QEEE.ExecutionMediator.Execution.ExecutionStatusResolver - Instance 0: Runtime status is updated to Done(micGeneral)
2013-11-26 05:16:19,059 [15] INFO - LogCatReplay - CProxy_IQTFuncLibMgrEvents::FireHelper Start. DispID = 5 Func=CProxy_IQTFuncLibMgrEvents<class CQTFuncLibMgr>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qtfunclibmgrcp.h Line=16 ThreadID=4636
2013-11-26 05:16:19,059 [15] INFO - LogCatReplay - UnitExecutionEngine: CProxy_IQTASUnitExecutionEngineEvents::FireHelper Start. DispID = 8 Func=CProxy_IQTASUnitExecutionEngineEvents<class CQTASUnitExecutionEngine>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qtasunitexecutionenginecp.h Line=15 ThreadID=4636
2013-11-26 05:16:19,059 [15] INFO - LogCatReplay - cCProxy_IQTTestExecutionEngineEvents::FireHelper Start. DispID = 16 Func=CProxy_IQTTestExecutionEngineEvents<class CQTTestExecutionEngine>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qttestexecutionenginecp.h Line=15 ThreadID=4636
2013-11-26 05:16:19,059 [1] INFO - LogCatReplay - ExecutionSite: CProxy_IQTTestExecutionEngineEvents::FireHelper Start. DispID = 16 Func=CProxy_IQTTestExecutionEngineEvents<class CQTTestExecutionSite>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionsite\qttestexecutionsitecp.h Line=17 ThreadID=880
2013-11-26 05:16:19,059 [1] INFO - LogCatReplay - ExecutionSite: CProxy_IQTTestExecutionEngineEvents::FireHelper End Func=CProxy_IQTTestExecutionEngineEvents<class CQTTestExecutionSite>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionsite\qttestexecutionsitecp.h Line=41 ThreadID=880
2013-11-26 05:16:19,059 [15] INFO - LogCatReplay - ExecutionEngine: CProxy_IQTTestExecutionEngineEvents::FireHelper End Func=CProxy_IQTTestExecutionEngineEvents<class CQTTestExecutionEngine>::FireHelper File=e:\ft\qtp\win32_release\11.52.467.0_clean\qtp\backend\executionengine\app\qtexecutionengine\qttestexecutionenginecp.h Line=52 ThreadID=4636
答案 0 :(得分:1)
如果您使用声明记录器的标准方法,例如
internal static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
然后在您的log4net配置文件中,您可以根据您的类的名称空间禁用除您自己的代码之外的日志记录。
例如,如果您只想记录来自TKS.DataDriver的行,那么您的配置文件可能包含类似
的内容<root>
<level value="OFF" />
<appender-ref ref="RollingFileAppender" />
</root>
<logger name="TKS.DataDriver">
<level value="INFO" />
</logger>
如果需要,可以添加其他命名空间,或者只使用“TKS”等。