Skip to content

Instantly share code, notes, and snippets.

Created June 22, 2012 16:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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