如何(以编程方式,没有xml配置)使用Log4Net配置多个记录器?我需要他们写入不同的文件.
这是一个非常常见的问题,但我无法得到工作的答案.这是我的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="CraneUserInterface.log" />
<appendToFile value="true" />
<maxSizeRollBackups value="90" />
<rollingStyle value="Size" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
Run Code Online (Sandbox Code Playgroud)
But I need to determine the actual logging file name at run time. I found a nice example here, but when I try to loop through the collection returned by the call to GetIterators(), I find that that collection is empty.
I …
我使用%property%来设置Log4Net配置文件中的输出文件路径.每次应用程序启动时,都会在APP数据文件夹中创建一个日志文件.我正在使用Composite滚动样式来滚动文件.
但现在我的要求是根据应用程序中的一些用户交互来滚动/更改文件路径.我怎样才能实现这一目标,任何人都可以建议我实现这一目标.
如果我的要求不明确,请告诉我.
谢谢.
将日志保存到 Azure Blob 存储时,是否可以每天创建不同的文件夹?现在我正在使用这个配置,它工作正常
<appender name="AzureAppender2" type="log4net.Appender.AzureBlobAppender, log4net.Appender.Azure">
<param name="ContainerName" value="testcon" />
<param name="DirectoryName" value="myfolder/logs.txt" />
<param name="ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=testcon;AccountKey="rftgdfgdfgfdg78=="/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
Run Code Online (Sandbox Code Playgroud)
我已经试过了
<param name="DirectoryName" value=%date/" />
Run Code Online (Sandbox Code Playgroud)
但它不起作用
我想要的是能够每天动态使用不同的文件夹:比如
目录名称 = 2016-05-13
目录名称 = 2016-05-12
目录名称 = 2016-05-11
这是可以实现的吗?
谢谢
log4net azure log4net-configuration log4net-appender azure-blob-storage