NuGet npm Samples

Logging to elmah.io from Vue

To log all errors from a Vue.js application, install the elmah.io.javascript npm package as described in Logging from JavaScript or include it with a direct <script> include:

<script src="https://cdn.jsdelivr.net/gh/elmahio/elmah.io.javascript@latest/dist/elmahio.min.js" type="text/javascript"></script>

Before initializing the application, include the following code:

var logger = new Elmahio({
  apiKey: "API_KEY",
  logId: "LOG_ID"
});
Vue.config.errorHandler = function (err, vm, info) {
  logger.error(err.message, err);
};
Vue.config.warnHandler = function (msg, vm, trace) {
  logger.warning(msg);
};

elmah.io.javascript will automatically log all errors raised through window.onerrorand log additional errors and warnings from Vue.js through the errorHandler and warnHandler functions. If you want to exclude warnings, simply remove the warnHandler function.

Check out the Elmah.Io.JavaScript.VueJs sample for some real working code.


This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website