質問

I want to write logs to current date directory for ASP.NET site by using Log4Net lib.

Like this: <file value=".\Content\logs\{$currentDate}\TestLog.log" />

How I can do this?

役に立ちましたか?

解決

You can use log4net.Util.PatternString to do this, in your case do the following:

Remove this:

<file value="TestLog.log" /> 

And add this:

<file type="log4net.Util.PatternString" value=".\Content\logs\%date{yyyyMMdd}\\TestLog.log" />

For further info please refer to the documentation:

https://logging.apache.org/log4net/release/sdk/log4net.Util.PatternString.html

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top