我正在使用log4net Azure附加程序,我的目标是删除不必要的属性,并在Azure Blob存储中添加一些要记录(附加)的属性。 无需尝试创建自己的附加程序,我将如何做到这一点?
似乎仅将某些属性保留为null不会使.DoAppend方法记录任何内容。
AzureAppendBlobAppender _appender = new AzureAppendBlobAppender()
{
ConnectionString = "myConnString",
ContainerName = "logs",
DirectoryName = "logs"
};
_appender.BufferSize = 1;
_appender.ActivateOptions();
var logEvent = MakeEvent();
_appender.DoAppend(logEvent);
private static LoggingEvent MakeEvent()
{
return new LoggingEvent(
new LoggingEventData
{
Domain = "testDomain",
Identity = "testIdentity",
Level = Level.Critical,
LoggerName = "testLoggerName",
Message = "testMessage",
ThreadName = "testThreadName",
TimeStamp = DateTime.UtcNow,
UserName = "testUsername",
LocationInfo = new LocationInfo("className", "methodName", "fileName", "lineNumber")
}
);
}