Introduction

“App Logging” is a logging framework that enables to emit logging and debug information to multiple destinations. These logs can be categorized into categories and can be configured for each app and category and even user and where logs should be emitted.

Using this logger is really simple. You just have to follow these steps:

  1. Declare a variable for codeunit 70623694 EOS004 App Logger
  2. Initialize the codeunit using either Initialize or InitializeForCaller
  3. Emit log messages using the LogMessage methods. They are very similar to the ones used by Session.LogMessage and therefore shouldn’t give you much trouble.

You can find a more detailed example on https://github.com/EOS-Solutions/Sample/tree/master/EX004.EosAdminLib/Logging

The following log destinations are currently supported:

Application Insights (Default)

This is essentially the same as using Session.LogMessage. This will emit logs to the application insights account that is defined on the app and/or on the service. The benefit of using the App Logging framework instead of calling Session.LogMessage directly is that this is part of the “App Logging” framework, and thus these log messages are now configurable per user/app/category. This logger does not buffer messages and thus does not require flushing.

Application Insights (Custom)

This is similar to Application Insights (Default), but allows to you to emit log messages to an arbitrary Application Insights account and is not limited to the ones defined in the app / service. This logger buffers its messages and therefore requires flushing to send them.

Internal

This is a logger that will log messages into a global temporary table that lives as long as the user session lives. You can use codeunit 70623696 EOS004 Internal Logger to access the logs that have been collected and export or persist them in whatever way you need. This logger does not buffer messages and thus does not require flushing.

Setup

You can find the setup for “App Logging” on the page App Log Setup (EAL).


Here you can see a list of all currently active and configured loggers.

  • App Name indicates the app fpr this logger configuration.
  • Name specifies the category for this logger configuration.
  • Username specifies the user for whom this logger configuration is active. This can be a single user or all users.
  • Enabled specifies if theconfiguration is currently enabled
  • Enabled From / Enabled to specifies the date/time range in which this logger will be enabled. If this is not specified, the logger is always active. In addition to this date/time range, the flag Enabled also needs to be active.
  • Logger specifies the logger to which this configuration will write its log messages to.
  • Service Config. Code specifies the service configration to use for the logger specified in Logger. This might not be necessary and it depends on the logger selected in Logger how and what should be selected here. At the moment, only Application Insights (Custom) requires a service configuration. Read more on this in Service configurations.
  • Diagnostics Key is a randomly generated key that is sent along with any log messages that are written for this configuration. This helps you identify the configuration when analyzing your logs.

Using the New action, a new configuration can be created.


The following fields are required:

  • App Id specifies the app for which to create a logger configuration. You will only see apps in this list that have subscribed to the event OnCollectLogCategories and have provided at least one log category. Check the sample on GitHub for details on how to implement this.
  • App Name shows the name of the app you selected.
  • Category lets you choose the log category for which you want to create the configuration. The values available are the value that the app provides through OnCollectLogCategories.
  • Enabled For lets you choose if the configuration should be valid for all users, the currently logged in user or a specific user only.
  • Username lets you choose the user for which you want to configure this log, if you have selected Specific User in Enabled For.

EOS Labs -