0

I have the next logger config and when the size of file reaches 10mb it is rewritten. This is bad for me. I want log4net to continue writing in the file. How is it possible?

I don't want to set any limits for generating the file. Which settings should I configure/edit for that?

<?xml version="1.0"?>
<logger>
  <path>C:\</path>
  <file>dd-MM-yyyy'.log'</file>
  <levels>
    <add>ERROR</add>
    <add>INFO</add>
  </levels>
  <pattern>{level}|{date}|{method_guid}|{method_name}|{description}|{status}|{msg}|{inout}|{param0}</pattern>
  <dateFormat>MM/dd/yy H:mm:ss.fff</dateFormat>
  <reloadEveryMinutes>1</reloadEveryMinutes>
  <appendToFile value="true" />
</logger>
FortyTwo
  • 2,414
  • 3
  • 22
  • 33
John
  • 81
  • 1
  • 6
  • 1
    Are you sure you want to have a log file which can virtually grow to petabytes? – Gusman May 30 '17 at 20:34
  • 1
    Possible duplicate of [Maximum Filesize of LogFileAppender in Log4Net](https://stackoverflow.com/questions/641226/maximum-filesize-of-logfileappender-in-log4net) – sab669 May 30 '17 at 20:36
  • @Gusman yes. i am sure – John May 30 '17 at 20:38
  • 2
    it is much better to use log4net.Appender.RollingFileAppender then you can technically log everything, and still keep the logs small in size. 1 big log file is not a good idea – Droa May 30 '17 at 20:38
  • @droa Can I not set the count of generating files? – John May 30 '17 at 20:42
  • you can just count the files of the naming format, RollingFileAppender just add a number after the name dd-MM-yyyy.log dd-MM-yyyy.log.1 dd-MM-yyyy.log.2 dd-MM-yyyy.log.3 etc – Droa May 30 '17 at 21:33
  • sorry, I misunderstood the question, but I found you an answer if you can set a max limit. the short answer is yes, look at this: https://stackoverflow.com/questions/95286/log4net-set-max-backup-files-on-rollingfileappender-with-rolling-date – Droa May 31 '17 at 17:11

0 Answers0