Log4Net RollingFileAppender composite element with static file extension

Does the current version of Log4net have a way to create a RollingFileAppender with a composite rolling style in which minimized files always save this extension (.log in my case)?

An example of the format I would like:

Mylog.log
MyLog.2011-04-10.1.log
MyLog.2011-04-10.2.log
MyLog.2011-04-10.3.log

I found this post that says there is a PreserveLogFileNameExtension property, but it is not included in the official binaries. Is this still true?

If yes: can anyone explain why this property is still not an official part of Log4Net? I'm a bit skeptical about using custom assembly, but maybe I shouldn't be?

I am also interested to know why the function does not save the file extension by default. I do not understand why it will force the user to have all the log files have different extensions.

Edit: Got this by doing this:
1: Download and build the log4net source code
2: Applying these patches: https://issues.apache.org/jira/browse/LOG4NET-64
3: Setting PreserveLogFileNameExtension to "true" in the configuration.

+4
source share
3 answers

The situation has not changed. There is no new version of log4net. It is completely incomprehensible to me when (if) a new release appears ...

I think you don’t have to worry much about using custom assembly. Check your software, if it works, it is good enough.

EDIT . A new version has appeared that should include LOG4NET-64. Of course, you can still stick with your custom build.

+2
source

Have you tried these options?

<file value="log-files\MyLog" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <datePattern value="yyyy-MM-dd'.log'" /> <param name="StaticLogFileName" value="false" /> 

It will save the extension, but give you a date in every file name like this.

  MyLog2011-05-16.log 
 MyLog2011-05-17.log 
 MyLog2011-05-18.log 
 MyLog2011-05-19.log 

Maybe this can be combined with size?

+4
source

I am using this configuration:

 <file value="" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <datePattern value="yyyyMMdd'.log'" /> <staticLogFileName value="false" /> 

To get file names, for example:

  • 20111101.log
  • 20111102.log
  • 20111103.log
0
source

Source: https://habr.com/ru/post/1347526/


All Articles