log4net one file per run -
Every time I run it, I need my application to create a log file.
My preferred format will be App.log.yyyy -mM-dd_HH-MM-SS . If this is not possible, then I want to decide for App.log.yyyy-MM-dd.counter
This is my current appender configuration:
& lt; Appender name = "file" type = "log4net.Appender.RollingFileAppender" & gt; & Lt; File value = "App.log" /> & Lt; Rolling style value = "date" /> & Lt; DatePattern value = ".yyyy-MM-dd_HH-mm-ss" /> & Lt; StaticLogFileName value = "wrong" /> & Lt; Locking model type = "log4net.Appender.FileAppender + MinimalLock" /> & Lt; / Appender & gt;
But it creates several random files based on date and time.
I think every time the application should be created, only one log file should be created, The adender is not required (though my solution will also apply to rolling file appenders):
& lt; Appender Name = "File Affair" type = "log4net.Appender.FileAppender" & gt; & Lt; File type = "log4net.Util.PatternString" value = "c: \ temp \ application-% dated {yyyy-MM-dd_HH-mm-ss} .log" /> & Lt; AppendToFile value = "true" /> & Lt; Layout type = "log4net.Layout.PatternLayout" & gt; & Lt; Conversion value value = "% date [% 2 thread]% -5 level -% message% newline" / & gt; & Lt; / Layout & gt; & Lt; / Appender & gt;
(Obviously you can use your own layouts and other settings for file appenders.)
Comments
Post a Comment