How to Configure Email AlertsIntroduction:There is no native error notification system available, however the internal (open source) logging engine used by the Layer2 Cloud Connector allows many adjustments that include different notification variations. The logging Software used is called NLog, we recommend checking out their documentation: https://github.com/nlog/nlog/wiki. Any message that is created by the Cloud Connector, will be handed by NLog. The logging configuration file (Nlog.config) is located in the directory 'C:\ProgramData\Layer2 Cloud Connector\Logs\'. This file contains all logging-specific configuration settings and defines different log formats for the Connection Manager and the background Windows Service log files.
Configuration of Email Alerts:Add two BufferingWrapper targets which are used to bulk send messages instead of sending a separate email for each log message as this would most likely flood your inbox:
<target xsi:type="BufferingWrapper" name="IssueMailBuffer" bufferSize="20971520" flushTimeout="10000" slidingTimeout="False" overflowAction="Flush"> <target xsi:type="Mail" name="IssueMailTarget" subject="Synchronization Issue in connection ${event-context:ThreadContextIdentifier}" body="${message}" from="cloudConnector@myCompany.com" to="me@myCompany.com" smtpUserName="cloudConnector@myCompany.com" smtpPassword="myPassword" smtpAuthentication="Basic" smtpServer="mail.myCompany.com" smtpPort="587" /> </target>
<target xsi:type="BufferingWrapper" name="SummaryMailBuffer" bufferSize="20971520" flushTimeout="10000" slidingTimeout="False" overflowAction="Flush"> <target xsi:type="Mail" name="SummaryMailTarget" subject="${replace:replaceWith=$1:regex=true:inner=${message}:searchFor=[^']*'([^']*)'[^']*} " body="Date: ${date:format=MM/dd/yyyy HH\:mm\:ss} ${newline} Performed Syncs: ${counter:increment=1:sequence=Layout:value=1} ${newline} Summary: ${message}" from="cloudConnector@myCompany.com" to="me@myCompany.com" smtpUserName="cloudConnector@myCompany.com" smtpPassword="myPassword" smtpAuthentication="Basic" smtpServer="mail.myCompany.com" smtpPort="587" /></target>
The targets have different names, so that they can be triggered by different rules (see below). The parameter in the subject line is the connection name so that you immediately can identify which connection is affected/referenced. You need to configure the SMTP-Parameters according to your SMTP setup. Note, that you need to have a whitespace (blank) after each ${newline} to enforce the new line to be inserted.
The SummaryMailBuffer target is used to send an alert that looks like You certainly can omit/delete it, if you do not want to get this information.
Add two rules which define when the targets are triggered:
<logger minlevel="Warn" name="*" writeTo="IssueMailBuffer" /> <logger minlevel="Info" name="*" writeTo="SummaryMailBuffer"> <filters> <when condition="not equals('${level}', 'Info')" action="Ignore" /> <when condition="not contains('${message}', ' finished:')" action="Ignore" /> <when condition="contains('${message}', ' finished:')" action="Log" /> </filters> </logger>
The first rule configures that the IssueMailBuffer is triggered for all messages that have log level Warn or higher, which is Warn, Error and Fatal.
The second rule configures that the SummaryMailBuffer is triggered for all messages that have log level Info or higher (which would be Info, Warn, Error and Fatal) BUT using the filters, it is avoided that all these messages are sent. The filters define that message with log level other than Info are ignored as well as message which do not contain the string “finished:”, which only occurs in the summary log message. The last filter (not 100% sure, whether it’s required) explicitly specifies that in case the message contains “finished:”, it is logged.
After you copied the file and configured the SMTP parameters, please restart the Layer2 backend service and check whether you receive the emails as expected. |