私はlog4net.ext.jsonを使用して、 'message'プロパティーをログにシリアル化しています。しかし、標準設定を使用すると、 'message'オブジェクトは別のオブジェクトのプロパティとして含まれます。log4net.ext.json:メッセージプロパティーだけを記録する
がここに私の構成
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<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' /><!--add raw message-->
</layout>
</parameter>
記録されたデータであるが、単にメッセージオブジェクトをログに記録しない、そのようなAPPNAME、レベル、および例外などの他のコンテキスト情報を含みます。
これは、追加されたスタックトレーステキストがデータベースの最大フィールドサイズを超えることがあるため、例外が記録されると問題になります。
date": "2016-05-20T09:06:18.6288814+10:00",
"level": "WARN",
"appname": "/LM/W3SVC/3/ROOT-1-131081726390968061",
"logger": "DefaultLogger",
"thread": "10",
"ndc": "(null)",
-"message": {
"Message": "Model validation errors",
"Method": "LogValidationErrorsAttribute.OnActionExecuting",
"IsLocal": true,
"IsAuthenticated": false,
"IsSecureConnection": false,
"HttpMethod": "POST",
"CurrentUICulture": "en",
"CurrentCulture": "en",
}
私がやりたいことすべては、この特定のパラメータでロギングイベントオブジェクトのだけ「というメッセージ」プロパティを記録しています。
基本的には、ログに次のようになります。
{
"Message": "Model validation errors",
"Method": "LogValidationErrorsAttribute.OnActionExecuting",
"IsLocal": true,
"IsAuthenticated": false,
"IsSecureConnection": false,
"HttpMethod": "POST",
"CurrentUICulture": "en",
"CurrentCulture": "en",
}
任意のアイデアはどのようにこれを行うには?