我日志中的示例行可能如下所示:
{"日期":" 2015-05-20T16:33:52.2825750-05:00""电平":" INFO&#34 ;,"网站名称":" sitenamehere""记录器":" loggergoeshere""螺纹":&#34 ; 6"" property.ApplicationName":" AppnameWithPrefix"" property.Username":" USER"" property.log4net:身份":""" property.EnvironmentName":"本地"" property.log4net:用户名" :" USER"," property.log4net:HostName":" HOST"," message":" MassTransit v2.9.2 / v2.9.0.0,.NET Framework v4.0.30319.34209"," ApplicationName":" AppnameWithoutPrefix"," EnvironmentName":" local& #34;"用户名":" USER"}
基本上,在该行的开头,ApplicationName
和EnvironmentName
的前缀为"属性。"我想摆脱那个。对于此应用程序的某些部分(特别是基于Web的内容),前缀不会显示。我无法弄清楚到底在做什么。
转换模式
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="%env{SPOTLITE_LOG_DIR}\%property{ApplicationName}\%property{ApplicationName}_%property{EnvironmentName}_%date{yyyy-MM-dd}.log" />
</file>
<appendToFile value="true" />
<rollingStyle value="Date" />
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
<decorator type='log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json' />
<default />
<!--explicit default members-->
<remove value='message' />
<!--remove the default preformatted message member-->
<member value='message:messageobject' />
<member value='ApplicationName' />
<member value='EnvironmentName' />
<member value='UserName' />
<!--add raw message-->
<!--add raw message-->
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
</appender>
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender,log4net">
<mapping>
<level value="FATAL" />
<foreColor value="White, HighIntensity" />
<backColor value="Red, HighIntensity" />
</mapping>
<mapping>
<level value="ERROR" />
<foreColor value="White" />
<backColor value="Red" />
</mapping>
<mapping>
<level value="WARN" />
<foreColor value="Yellow" />
</mapping>
<mapping>
<level value="INFO" />
<foreColor value="Green" />
</mapping>
<mapping>
<level value="DEBUG" />
<foreColor value="White" />
</mapping>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>