0

We are evaluating options to send the Sitecore application logs to New relic which is an application monitoring tool that also can index logs, so in the process of that, we found Serilog can write logs to New relic but the question here is how do I configure Serilog in Sitecore 9.3?

All the links and documentation in Sitecore point to the .Net Core version but we still use the .Net framework so any help would be appreciated.

1 Answer 1

1

The documentation you have read was probably for Sitecore Commerce (XC) which is built using .net Core. You cannot use Serilog with Sitecore XP as XP is using log4net to do the logging.

However for your use case with New Relic, you can configure custom appender for log4net that will log Sitecore events to New Relic.

  1. You need to create your custom log4net appender that will be using NewRelic.LogEnrichers.Log4Net npm package.

  2. Then you need to configure appender similarly to other appenders that are present in Sitecore (check showconfig.aspx).

Similarly to this:

<log4net>
    <appender name="NewRelicLoggingAppender" type="AssemblyName.Project.NewRelicAppender, AssemblyName.Project">
      <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>
    <logger name="AssemblyName.Project.NewRelicLogging" additivity="false">
        <level value="INFO" />
        <appender-ref ref="NewRelicLoggingAppender" />
    </logger>
</log4net>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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