1

I've trying to implement RollingAppender for general log files in sitecore 8.1 update 2 solutions.

The moment I change below

<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
  <file value="$(dataFolder)/logs/log.{date}.txt" />
  <appendToFile value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
  </layout>
  <encoding value="utf-8" />
</appender>

to

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
  <file value="$(dataFolder)/logs/log.{date}.txt" />
  <appendToFile value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
  </layout>
  <encoding value="utf-8" />
</appender>

the log files are not creating.

Exact config I am using in solution is:

 <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/log" />
    <appendToFile value="true" />
    <datePattern value="yyyyMMdd&quot;.txt&quot;" />
    <rollingStyle value="Composite" />
    <maxSizeRollBackups value="-1" />
    <maximumFileSize value="50KB" />
    <preserveLogFileNameExtension value="true" />
    <staticLogFileName value="false" />
    <immediateFlush value="true"/>
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
    </layout>
    <encoding value="utf-8" />
  </appender>

What am I missing here?

  • by size and date, I mean composite mode – nari447 Nov 9 '18 at 7:33
  • Was this resolved? – Mark Cassidy Dec 10 '18 at 11:08
  • Best way to figure out the issue is to enable debug mode of log4net Check this out stackoverflow.com/questions/756125/… – Jaffal Dec 10 '18 at 11:16
  • Is the datepattern correct? I've done somethign similar before but that property look like: <datePattern value="'.'yyyyMMdd'.txt'" /> Do be aware it occasionally stops logging when you recycle application pool. – josedbaez Dec 10 '18 at 13:28
1

As you would like to use Composite style, you are missing couple of configuration entries in your config.

You need to change your config like this (change values according to your needs):

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
  <file value="$(dataFolder)/logs/log.txt" />
  <appendToFile value="true" />
  <rollingStyle value="Composite" />
  <datePattern value="yyyyMMdd" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="1MB" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
  </layout>
  <encoding value="utf-8" />
</appender>

Take a look in more examples here: https://logging.apache.org/log4net/release/config-examples.html (Search for "RollingFileAppender")

  • I've tried te same way. did not work. I've updated the exact config Im using int he question. basically rollingfileappender is not working for me. – nari447 Nov 9 '18 at 7:42
  • I just found out that the logs are being created at the root of my C drive (c:\data\logs\..) instead of data folder of my sitecore website. any idea why the logs are not going to data folder of website? FYI- I've added this config as a patch config under app_config\includes.. – nari447 Nov 9 '18 at 9:26
  • can you change the file value to "$(dataFolder)/logs/log.txt" – Peter Procházka Nov 9 '18 at 9:39
  • tried "$(dataFolder)/logs/log.txt", but no luck.. log files are still not going to correct place – nari447 Nov 9 '18 at 10:11
  • 4
    I think the RollingFileAppender cannot evaluate the $(dataFolder) only the SitecoreLogFileAppender, so you need to specify the full path of the folder. – Tamas Varga Sitecore Nov 10 '18 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.