Integrating Papertrail logging in a .NET (NLog) application

Integrating Papertrail logging in a .NET (NLog) application

I’ve really come to enjoy Papertrail as an online log viewer. It’s super quick to setup and I can manage and view logs from multiple project and environments in one simple UI with searching, filtering etc.

Their service is free as long as you don’t use more than 2GB of log storage. And dont be afraid that you will all of a sudden be charged once you exceeded your quota.
 You don’t need to add any credit card information when registering. The only thing that will happen once you exceed 2GB is that papertrail will stop logging.
 You will still be able to read your logs the usual way.


The other day I got to set it up for yet another client so I thought why not document my steps and share it here.

  1. Create an account at https://www.papertrail.com
.

  2. Install NuGet package NLog.Targets.Syslog.

  3. Update your NLog config, usually in your web.config:
 enter image description here Click here to open code is gist file.

  4. Update the above snippet with the Papertrail endpoint and port that you received in step 1.

And that’s it! Now all your logs will be sent to Papertrail in addition to how they work already. Papertrail is just an additional target for your logs to be sent.

You can have all your logs sent to one place, and you can group them based on projects, environments etc. It’s super useful if you are using load balancing and have multiple frontend servers. Enjoy!

Take care of each other.

Cheers friends! ❤️