Layer2 Cloud Connector Logging and Alerting

The Layer2 Cloud Connector creates a variety of messages about its activities during synchronization. These messages will at first be filtered by the current global log level. Any message that gets through to this filter will be handed to the logging subsystem NLog. NLog is a free logging framework used by the Layer2 Cloud Connector system to manage its logging activities.

On this page you will learn how to find and configure own alerts in the Layer2 Cloud Connector.


 

 

How to find log information in the Layer2 Cloud Connector?

 

​By default, there will be one log file created for each connection. These files will be saved in the Logs subdirectory under the Layer2 Cloud Connecter data directory (usually here: C:\ProgramData\Layer2 Cloud Connector\Logs\) and they are named after the connection they belong to plus the .log extension. Also located in the Logs folder is the logging configuration file (Nlog.config). This file contains all logging-specific configuration settings and defines different log formats for the Connection Manager and the background Windows Service log files.

 

In the log configuration, file target is enabled by default. There are also example configurations for using the Windows Event Log, Email, or SQL databases.

 

More detailed information about how to configure NLog can be found in the NLog documentation at https://github.com/nlog/nlog/wiki.

Layer2 Cloud Connector Log to Windows Event Log

To configure the Layer2 Cloud Connector for logging into the Windows Event Log, a target section in the log configuration file needs to be created, similar to the following.

 

<target xsi:type="EventLog" name="EventLogTarget" layout="${message}" source="Layer2 Cloud Connector" log="Application"/>

 

xsi:type

 

Def;, but there is a variety of different target types to use. The NLog documentation can be referred for a complete reference.

 

 

name

 

This attribute contains the name of the target to reference it in the rules configuration.

 

 

layout

 

This defines the layout of the log message to be written to the event log. It can contain several placeholders of the format ${placeholderName}. The NLog documentation can be referred for a complete reference.

 

 

source

 

The name of the source to appear in the Windows Event Log.

 

 

log

 

The name of the event log to write to.

 

 

IMPORTANT: To make the new target work, it is necessary to define a logging rule in the configuration similar to the following. This is placed in the bottom section for <rules>.

 

<rule minlevel="Warn"
name="*"
writeTo="EventLogTarget" />

Layer2 Cloud Connector Email Alert Configuration

 

To configure the Layer2 Cloud Connector for sending e-mails for specific log-messages, a target section in the log-configuration file needs to be created, similar to the following.

 

<target xsi:type="Mail"
 name="MailTarget"
 subject="Synchronization Error"
 body="${message}"
 from="cloudConnector@myCompany.com"
 to="me@myCompany.com"
 smtpUserName="cloudConnector@myCompany.com"
 smtpPassword="myPassword"
 smtpAuthentication="Basic"
 smtpServer="mail.myCompany.com"
 smtpPort="587" />

 

xsi:type


Defines the type of target to log to. For mail alerts this needs to be “Mail”, but there is a variety of different target-types to use. The NLog documentation can be referred for a complete reference.

 

 

name

 

This attribute contains the name of the target to reference it in the rules configuration.

 

 

subject

 

This defines the subject of the mail alert. It can contain several placeholders of the format ${placeholderName}. The NLog documentation can be referred for a complete reference.

 

 

body

 

This defines the body-text of the mail alert. It can contain several placeholders of the format ${placeholderName}. The NLog documentation can be referred for a complete reference.

 

from

 

This attribute contains the email address of the sender.

 

 

to

 

This attribute contains the email addresses of the receipients, separated by semicolons.

 

 

smtpUserName and smtpPassword

 

These settings specify the account on the mail-server to be used to send the email alert.

 

 

smtpServer

 

SMTP server that'll be used to send the mail

 

 

smtpPort

 

Port number that you SMTP server is using. Note: port 465 doesn't work with SSL

 

 

smtpAuthentication

 

Defines the authentication mode to use when authenticating against the SMTP-mailserver. It can be one of the following:

 

None

Anonymous access to the mailserver. Username and password is not necessary with this setting.

 

 

Basic

 

Basic username and password authentication.

 

 

Ntlm

 

NTLM-Authentication. Username and password is not necessary with this setting.

 

 

If your email client also requires SSL connection to allow you to send mail, you may also need to include the parameter:

enableSsl="true"

 

 

IMPORTANT: To make the new target work, it is necessary to define a logging rule in the configuration similar to the following. This is placed in the bottom section for <rules>.

 

<logger minlevel="Error"
name="*"
writeTo="MailTarget" />

 

 

 

Synchronization Summary Alert

 

 

Additionally to the mail target function you can make use of the BufferingWrapper function and add a summary functionality that sends out an email as soon as a sync is finished. This is especially useful for scenarios where your syncs are scheduled on a daily basis to get informed of finished syncs even if it finishes without errors. Please note: This is advanced coding and should only be performed by a user with sufficient xml coding knowledge.

 

The following code snippet contains an example of what your sync summary could look like.

 

 

 

<target xsi:type="BufferingWrapper"
name="MailBuffer"
bufferSize="20971520"
flushTimeout="10000"
slidingTimeout="False"overflowAction="Flush">


<target xsi:type="Mail"
layout="${message}"
html="false"
subject="${replace:replaceWith=$1:regex=true:inner=${message}:searchFor=[^']*'([^']*)'[^']*} "
to=" name@mycompany.com "from=" name@mycompany.com "
body="Date: ${date:format=MM/dd/yyyy HH\:mm\:ss} ${newline}
Performed Syncs: ${counter:increment=1:sequence=Layout:value=1} ${newline}
Summary: ${message}"smtpUserName="name@mycompany.com"
smtpPort="587"
enableSsl="true"
smtpPassword="XXX"
smtpAuthentication="Basic"
smtpServer="smtp.office365.com" />
</target>

 

This will result in a mail that will look like this:

 

MailTargetSummeryExample

 

Further information about BufferingWrapper can be found in the NLog documentation.

Layer2 Cloud Connector Log to SQL Databases

 

Please use the example Database target that is given in the Nlog.config file (usually located here: C:\ProgramData\Layer2 Cloud Connector\Logs\Nlog.config). This has the correct formatting to ensure all logs are passed to SQL without syntax errors.

 

To use a database target, a connection string must be edited and a target table must be created.The required SQL script to create an appropriate table called "CloudConnectorLogs" is also placed in the configuration file as a comment. The NLog documentation can be used for a complete reference.

 

 

IMPORTANT: To make the new target work, it is necessary to define a logging rule in the configuration similar to the following. This is placed in the bottom section for <rules>.

 

<logger minlevel="Warn"
name="*"
writeTo="SqlTarget" />

Known Issues and Troubleshooting Information

 

  • The Layer2 Cloud Connector service does not pick up on logging changes (either Global Logging Level or customizations to the Nlog.config file) until the service is restarted.
  • If you try to set up mail target logging and you don't receive any mails check if the used account is either disabled, locked or if the password expired. In some cases it can be help to reset the password. 
  • If you face authentication issues while setting up the SMTP part of mail target logging you can find further troubleshooting steps in this blog article.
  • NLog has its own internal logging that can be used to troubleshoot (more information regarding this feature, see the NLog Documentation). You need to add the following to the <nlog> node to enable it, where <path> equals a location on the host machine that the log file will be written to:

 

<xml version="1.0" encoding="utf-8"?>
<configuration> <nlog internalLogFile="<path>" internalLogLevel="Trace">

 

Need More Help?

For technical questions or additional help with errors, please contact support@layer2solutions.com.

Ready to go next steps?

Layer2 leading solutions product regsitration icon: a grey square with a big orange pen symbol.

Register for free download.

Keep your systems in sync now. Download and try the Layer2 Cloud Connector today.

Contact Us Icon for Layer2 leading solutions

Questions? Contact us.

We are here to help. Contact us and our consulting will be happy to answer your questions.