kamsar / Dianoga

An automatic image optimizer for the Sitecore media library.
Other
102 stars 45 forks source link

Add ability to silence logs or use Trace/Debug log level #92

Closed AdamHess closed 3 years ago

AdamHess commented 3 years ago

While I love seeing the details, my logs are getting flooded by every image Dianoga optimizes.

Unless I missed it, I would appreciate the ability to turn off logging from Dianoga.

Alternatively, you could use a lower logging level such as DEBUG since the compression status is not useful for determining the health of the application and more for debugging underlying what's going on.

markgibbons25 commented 3 years ago

What would people prefer? A separate logger for Dianoga so you can set the log level and use whatever appender you want? (use rocket emoji) Or simply a new setting that you set the log level and it still uses the standard Sitecore logger? (use heart emoji)

weirdpattern commented 3 years ago

I like the idea of a separate logger for Dianoga, but for those waiting, here is an easy fix for the logs... hope this helps somebody

<?xml version="1.0"?>
<configuration>
  <sitecore>
    <log4net>
      <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
        <filter id="Dianoga Filter" type="log4net.Filter.StringMatchFilter">
          <stringToMatch value="Dianoga:" />
          <acceptOnMatch value="false" />
        </filter>
      </appender>
    </log4net>
  </sitecore>
</configuration>

You can go a little more specific if needed to by replacing "Dianoga:" with "cannot be optimized due to media type or path exclusion" or whatever other message you want to ignore.