Email Error Logger

Email Error Logger

The email error logger sends emails when a FATAL error is logged in the KODIAK Oms Order Entry Server. To enable the Email error logger you must uncomment all the lines in the log4net.config in the C:\KodiakOrderEntryServer\Config\ directory.

For example:

<logger name="Genium.DropCopy.Events" additivity="false"> <level value="TRACE"/> <appender-ref ref="Genium.DropCopy.Events.Appender"/> <!--<appender-ref ref="EmailErrorLog" />--> </logger>

Should be and this should be done in all occurrences of the commented EmailErrorLog

<logger name="Genium.DropCopy.Events" additivity="false"> <level value="TRACE"/> <appender-ref ref="Genium.DropCopy.Events.Appender"/> <appender-ref ref="EmailErrorLog" /> </logger>

Here is an example of the EmailErrorLog appender:

<!-- Email Error Logger configurations can be changed here--> <appender name="EmailErrorLog" type="log4net.Appender.SmtpAppender"> <!-- Email address to send error log to, multiple addresses can be configured by adding "," between email addresses --> <to value="XXXX" /> <!-- Email address to send error log from--> <from value="XXXX" /> <!-- Email subject, must remove TEST when run in production --> <subject value="Kodiak OMS Order Entry Server Error" /> <!-- Email SMTP server address --> <smtphost value="XXXX" /> <!-- TCP port used for the SMTP connection. Port 587 is the modern STARTTLS submission port; Office 365 accepts 25 or 587. If omitted, .NET’s SmtpClient uses 25.--> <port value="25"/> <!-- Number of log events queued before an email is sent. Setting it small (or 1) sends a message almost immediately; larger buffers reduce email volume at the cost of delayed alerts. 0 (or omitting the tag) means “send every event immediately.”--> <bufferSize value="1"/> <!-- Tells SmtpAppender to log in to the SMTP server. Acceptable values: None, Basic, Ntlm. If omitted, the default is None.--> <authentication value="None"/> <!-- If using Basic or Ntlm you must provide usernamr and password <authentication value="Basic" /> <username value="XXXX" /> <password value="XXXX"/> --> <!-- If authentication is Basic or Ntlm EnableSsl must be set to true for Office 365/Exchange Online.--> <EnableSsl value="false" /> <lossy value="false"/> <threshold value="FATAL"/> <layout type="log4net.Layout.PatternLayout,log4net"> <conversionpattern value="%property{log4net:HostName} :: %level :: %message %newlineLogger: %logger%newlineDate: %date%newline" /> </layout> </appender>

XML element / attribute

What it means

Typical defaults / tips

XML element / attribute

What it means

Typical defaults / tips

<appender name="EmailErrorLog" type="log4net.Appender.SmtpAppender">

Declares an appender named EmailErrorLog that uses the built-in SmtpAppender class. Multiple appenders can exist in one log4net config, each with its own name and type.

Name is arbitrary; type must be the fully-qualified class name.

<to value="magnus@kodi.is" />

Comma-separated list of recipients who will receive the email.

Supports plain addresses or “Display Name <address>”.

<from value="no-reply@fjarfestar.is" />

Sender address that appears in the From header. Must be valid for the SMTP server so that SPF/DMARC checks pass.

 

<subject value="Kodiak OMS Shortcode Service Error" />

Subject line of each email. You can include %level, %logger, etc. to inject runtime values.

Often appended with the process name or environment (e.g. “- DEV”).

<smtpHost value="smtp.office365.com" />

Hostname of your SMTP relay. If you omit it, log4net uses the system’s default pickup directory (IIS) or localhost.

 

<authentication value="Basic" />

Tells SmtpAppender to log in to the SMTP server. Acceptable values: None, Basic, Ntlm.

If omitted, the default is None.

<username value="no-reply@fjarfestar.is" />
<password value="password" />

Credentials used when authentication="Basic" or Ntlm".

Consider pulling these from the machine-level configProtectedData store or an environment variable instead of plain text.

<EnableSsl value="true" />

When true, the appender initiates a STARTTLS or SSL session (depending on server) to encrypt the connection.

Defaults to false; must be true for Office 365/Exchange Online.

<port value="25" />

TCP port used for the SMTP connection. Port 587 is the modern STARTTLS submission port; Office 365 accepts 25 or 587.

If omitted, .NET’s SmtpClient uses 25.

<bufferSize value="512" />

Number of log events queued before an email is sent. Setting it small (or 1) sends a message almost immediately; larger buffers reduce email volume at the cost of delayed alerts.

0 (or omitting the tag) means “send every event immediately.”

<lossy value="false" />

If true, events are silently dropped when the buffer is full; if false, overflowing the buffer forces an immediate send so nothing is lost.

Keep false for an error appender—dropped errors defeat the purpose.

<layout type="log4net.Layout.PatternLayout">

Governs how each log event is rendered into text that becomes the email body. PatternLayout lets you compose flexible templates using conversion specifiers.

Other layout choices: SimpleLayout, XmlLayout, custom layouts.

<conversionPattern value="%message%newline%newline%newline" />

Template used by the PatternLayout above. Here you include just the log message and then three blank lines. You could expand this to %date – %level – %logger – %message%newline%exception for richer info.

Remember %newline is platform-specific (\r\n on Windows).