Hey DEF 2.0 where have my batch messages gone?

If you are familiar with Data Exchange Framework you will know that apart from being able to run a number of pipelines, a Pipeline Batch can also provide summary information about the last time the batch was run:

  • Date & time the batch was last started.
  • Data & time the batch last finished.
  • Log Messages that were captured during the last time the batch ran.
  • Log Levels to determine what is written to the message log.

Prior DEF 2.0 the log messages were written to the Sitecore log file (by default) and written to the Messages field. You could also control the maximum number of messages that were written and displayed in the messages field.

def141batchsummary

DEF 2.0 you no longer have the messages field and messages are logged to a separate log file for each Tenant and Batch. When you run the batch the log is generated and the name of the log is written to the log field. You are provided with the last batch run log file name and some options to interact with this log file:

  • Download – downloads the file.
  • View – opens the file for viewing in Sitecore.
  • Clear – clears the name of the log file.

DEF20batchsummary

With a vanilla Sitecore 9 and DEF 2.0 install if you attempt to Download the log file nothing will happen and when you click on the View File to open the message log it does not open and if you click Open you’ll receive a YSOD with a NullReferenceException: Object reference not set to an instance of an object. If you check the file system you won’t find the log file either.

DEFmesssagelogysod

The Problem

All logs file paths are created as relative to the dataFolder, which by default points to the relative path of site root: “/App_data”. It seems that the PipelineBatchLog which is expected to generate log files based on the tenant and pipeline batch names fails to create log files when the DataExchange.LogFolder is set to a relative path, by default its set to “/App_Data/logs/Data Exchange”.

This has been identified as a bug which will hopefully be addressed in a future release. It can be tracked with the following reference number: 195928.

The Workaround

There is a workaround for this issue, simply change dataFolder from the default relative path to an absolute path for the folder:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
 <sitecore>
 <sc.variable name="dataFolder">
 <patch:attribute name="value">C:\inetpub\wwwroot\sc900.local\App_Data</patch:attribute>
 </sc.variable>
 </sitecore>
</configuration>

Once you’ve done that and run your batch again, your batch log files will be created and you can click the View Log which opens the Log Viewer and the log file automatically allowing you to easily view the messages contained in the log file within Sitecore and view the Message Log.

DEF20batchviewlog

I really like the way Sitecore has separated out the logs in DEF 2.0.  This makes it much easier to exam logs that are associated with a particular tenant and batch run. It also removes noise from the Sitecore logs. The PipelineBatchLog does not have a configurable Appender as it generates the logs that are based on tenants and batch names. The logs for each Tenant will be created within a subdirectory with the same name as the tenant and the log files will be prefixed with the name of the Pipeline Batch i.e. [Tenant Name]/PipelineBatchName.Date.Time.log.  The subdirectories by are created within $(dataFolder)/logs/DataExchange by default.  The default location is defined by the DataExchangeLogFileAppender which is configured in the Sitecore.DataExchange.local.config file.

<log4net>
   <appender name="DataExchangeLogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/DataExchange/log.{date}.{time}.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="-1" />
    <maximumFileSize value="10MB" />
    <layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
    </layout>
    <encoding value="utf-8" />
   </appender>
   <logger name="Sitecore.DataExchange.Local.Loggers.DataExchangeLog" additivity="false">
    <level value="INFO" />
    <appender-ref ref="DataExchangeLogFileAppender" />
   </logger>
   <logger name="PipelineBatchLog" additivity="false">
    <level value="DEBUG" />
   </logger>
 </log4net>

 

DEF 2.0.1

The bug will be fixed in DEF 2.0.1 which should be released soon according to Adam Conn. You can also contact Sitecore Support for a hotfix.

Hope you’ve found this helpful.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s