Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Custom NLog Target for sending log events via SMS using Twilio
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
namespace Twilio.Targets
public class Sms : NLog.Targets.TargetWithLayout
public string AccountSid { get; set; }
public string AuthToken { get; set; }
public string From { get; set; }
public string To { get; set; }
protected override void Write(NLog.LogEventInfo logEvent)
string logMessage = this.Layout.Render(logEvent);
private void SendTheMessageToTheRemoteHost(string message)
string msg = (message.Length > 160) ? message.Substring(0, 160) : message;
var client = new TwilioRestClient(this.AccountSid, this.AuthToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment