Sending Log Messages to Exceptionless

Exceptionless Log Message EventsWe’re all about exceptions, but sometimes, as developers, we run into bugs that don’t throw them but still cause major havoc in the system. There are also times we just need to record an event with a custom message to help track down bottlenecks, etc.

That’s where Exceptionless meets log messages.

In Exceptionless 2.0, you can now send custom log messages to a Log Messages dashboard where they can be tracked and view just like exceptions and other events.

Lets take a closer look…

How to Submit a Log Message to Exceptionless

Using the Client

For this example, we are assuming that you have already created an account and installed and configured the Exceptionless 2.0 client. If you are still using the 1.x client, you will need to upgrade to send us log messages. Please contact support via an in-app support message or our contact page if you have any questions or need assistance in this area.

Let’s submit a log message

using Exceptionless;
ExceptionlessClient.Default.SubmitLog("Application starting up");

That’s your basic log message.

Getting fancier, you can also specify the log source and log level.

In the below example, “typeof(MainWindow).FullName” specifies the log source, and “Info” specifies the log level. If no log source is specified, the log messages will be stacked under a global log stack.

We recommend specifying one of the following log levels, all of which add a visual indicator to each log message (see below screenshot).

  • Trace
  • Debug
  • Info
  • Warn
  • Error
ExceptionlessClient.Default.SubmitLog(typeof(MainWindow).FullName, "Info log example", "Info");

Here’s a screenshot of what the visual indicators for the different types of log levels look like.

Exceptionless Log Message Preview

You can also add additional information using our fluent API.

This is helpful wen you want to add contextual information, contact information, or a tag.

In the below example, we will use the “CreateLog” method to add a tag to the log message.

using Exceptionless;
ExceptionlessClient.Default.CreateLog(typeof(MainWindow).FullName, "Info log example", "Info").AddTags("Wpf").Submit();

There are a number of additional pieces of data you can use for your event. The below bullets include the current EventBuilder list, but we are always adding more that can be found on GitHub. Also, view more examples here on our Sending Events page.

  • AddTags
  • SetProperty
  • AddObject
  • MarkAsCritical
  • SetUserIdentity
  • SetUserDescription
  • SetVersion
  • SetSource
  • SetSessionId
  • SetReferenceId
  • SetMessage
  • SetGeo
  • SetValue
  • And more, depending on your client

Using the REST API

You can also submit a log message with an HTTP post to our events endpoint.

My log message
My second log message.

By default, any content that is submitted to the API post is a log message. The above example will be broken into two log messages because it automatically splits text content by the new line.

You can submit a log message via JSON, too.

See details in our API Documentation. If you need an API key for simply posting events, you can find it in your project settings. Otherwise, please refer to the auth login documentation to get a user scoped api key.

Below is a JSON example of a log message, with source, message, and log level.

  "type": "log",
  "source": "WpfApplication3.MainWindow",
  "message": "Application started",
  "data": {
    "@level": "Info",

Using NLog or Log4net Targets

We also have integrations with major logging frameworks. The benefits of using a logging framework is finer, more granular control over what is logged.

For example, you can log only warnings or errors project-wide, but then enable trace level messages for a specific class. We do this on our project to keep our system from getting filled up with noise that doesn’t add any value unless there is an issue.

This also allows you to quickly change what you want to log to. Maybe you want to turn off logging to Exceptionless, or log to Exceptionless and to disk.

NLog or Log4net Usage

To use the NLog or Log4net clients, you’ll just need to bring down the nuget package and follow the detailed readme. You can also take a look at our sample app, which uses both frameworks.

Note on performance: Use in-memory event storage for high volumes

There are some performance considerations you should be aware of when you are logging very high numbers of log events and using our client. We’ve spent a lot of time to ensure Exceptionless doesn’t degrade your applications performance. However, if you are logging thousands of messages a minute, you should use the in-memory event storage.

using Exceptionless;

This tells the client not to serialize the log events to disk before sending and thus is much faster (the client doesn’t need to serialize the event to disk and read it from disk before sending). This comes at the expense that if the application dies, you will lose any unsent events that were in memory. When you use the NLog or Log4net targets and specify the API key as part of the target configuration, we will automatically create a second client instance that uses in-memory storage only for log messages. This way, any logged exceptions or feature usages still use disk storage, while log messages use in-memory storage, allowing maximum performance.

Another Note: We are also working on updating the Serilog implementation.

Log Messages Dashboard

The Log Messages Dashboard makes it easy to see log occurrences. You can keep track of how active a component is, or how long code takes to execute using existing metrics.

For metrics, we have created an open source metrics library called Foundatio. We use it for Exceptionless, and think you will find it extremely helpful as well. Check it out! We’ll be posting an article on Foundatio soon, so check back.

How Are You Liking Exceptionless 2.0?

We think we’ve added some pretty cool features to Exceptionless 2.0, including logging, but you are the ultimate judge. What’s good? What’s bad? What’s missing? Let us know via a comment on the blog, social media, in-app, or however else you want to get in touch!

If you’re new to Exceptionless 2.0, make sure to check out the launch article for more details on the new features and enhancements.

  • Egor Nagorny

    Could you provide a video for this feature?

    • Blake Niemyjski

      What all would you like the video to contain?

      • Egor Nagorny

        I would like the video with “how to set logs in a project”

        • Blake Niemyjski

          We will be creating an overview video in a future blog post (we are trying to do two posts a week). If you want, I could give you an overview via remote session, just contact us via in app support or via our chat room.

          • Egor Nagorny

            I will wait, please give me a tip when it is ready

          • Blake Niemyjski


            I created a very quick video on how to submit a log message:

          • Egor Nagorny

            Thank you

  • Shengyan Cheng

    if possible to get the log json body before ex.ToExceptionless().submit()?

    • Blake Niemyjski

      Yes, you can do ex.ToExceptionless().SetProperty(“JSON”, myJsonVariable).Submit();

      • Shengyan Cheng

        thank you for your answer.
        but i mean only collect and keep log data to local file in my website. include exception , request, environment.
        then send these data to exceptionless server by another job

        • Blake Niemyjski

          In order to submit content to our server using our client you have to submit it. If you want to get the completed raw event with all the info you should hook up to the Submitted event handler and serialize the Event model on the event args or register a plugin with a high priority and serialize the event off the context. Is there any reason for getting the raw json? Also, depending on platform, there will be additional fluent methods off of ToExceptionless which allows you to set http context / action contexts etc so you can capture information like user / request.

          • Shengyan Cheng

            one of the reason is our website on the different network segment to access the same log server. e.g. AZURE. it might have cost more time. Even impact the website performance

          • Blake Niemyjski

            Everything is submitted on a background thread and shouldn’t impact app performance. If you have a very high throughput and latency of any kind is a concern/problem please contact us and with what you are seeing and we can go from there.

          • Shengyan Cheng

            Another reason is some system already had his log file, We just want to copy these exist files to the Exceptionless Server and use same data schema

          • Blake Niemyjski

            We don’t have anything out of the box that writes events to disk in a log file fashion and reads them from disk and submits them but this could be built. We do have the ability to write individual files (queue) to disk but this has serialization overhead, you may be able to steal most of this code and get it to work. It might be worth looking into something like and writing an exceptionless implementation. I hope this helps.

          • Shengyan Cheng

            I tried to use the client to keep raw data, but it seems impossible success to keep the environment and the request raw data. Could you further tip how to do it? or I will post my code tomorrow.

          • Shengyan Cheng
          • Blake Niemyjski

            You’re going to want to add a plugin ( with a priority over 100 (I’d say >=200). And then use the context to access the configurations dependency resolver to get an instance of IJsonSerializer. From here you can serialize it to a string and even post this raw string to our api if you’d like or use our serializer and convert it back into a model. Finally, if you don’t want it submitted you would want to set context.Cancel = true

          • Shengyan Cheng