我正在使用ASP.NET MVC和servicestack.logging,我使用过log4net。 我想在代码下面记录当前用户的机智:
private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Logger.Info(session.UserAuthId.ToString());
在web.config中
<appender type="log4net.Appender.RollingFileAppender" name="User_Log">
<file value="C:\logs" />
<datePattern value="dd.MM.yyyy'.log'" />
<appendToFile value="true" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
</layout>
</appender>
但是我在文本文件中看到了多余的日志:
如何清除log.txt中包含的以下消息?
Registering Reply service 'WorkshopService' with request 'my web api name'
Registering OneWay service 'UploadService' with request 'my web api name'
Registering OneWay service 'PostmanService' with request 'Postman'
Initializing Application my application name Services took 1177.0709ms. No errors detected.
有帮助吗?谢谢。
答案 0 :(得分:1)
这些日志消息来自ServiceStack.Host.ServiceController
类型的only logged in DebugMode,要隐藏它们,请不要启用调试记录器或filter logging messages from the specified type。