Reputation: 14155
I have some mvc4 application where I want to log when admin user is logged, when bad login is happen, crud operations, etc. Now everything works but I cannot see tree from the forest :) Too many information is logged, so I want to remove everything but my info which I explicitly set at contoller with log.Info("User is succ. login");
etc.
2013-03-27 20:25:11,285 [40] INFO NHibernate.Cfg.XmlHbmBinding.Binder - mapping collection: Domain.Model.Property.Photos -> Photo
2013-03-27 20:25:11,285 [40] INFO NHibernate.Cfg.Configuration - processing one-to-one association property references
2013-03-27 20:25:11,285 [40] INFO NHibernate.Cfg.Configuration - processing foreign key constraints
and bellow is over100 lines like this.
I was thinking that this is maybe I set up log xml configuration at application_startup
log4net.Config.XmlConfigurator.Configure();
and root appender is registered like this
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
</root>
So again, how to remove all this mapping and other information and log only my explicit log information with log.Info("some info");
Thanks
Upvotes: 0
Views: 203
Reputation: 6416
You can specify what information is logged by applying a conversionPattern to the appender.
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="C:\\Log\log.log"/>
<param name="AppendToFile" value="true"/>
<rollingStyle value="Size" />
<maxSizeRollBackups value="0" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level %logger [%ndc] - %message%newline"/>
</layout>
</appender>
Upvotes: 1