Integrating with Logging Framework

The logging framework integrations feature with Aptify is now available to help you monitor the health of your product and troubleshoot any problems you might have.

This allows us to add generic logging diagnostics to the product and allow our customers the flexibility to log to whatever infrastructure they want (event viewer, flat files, Splunk, the database, and so on)

The configuration and use of the integration of Logging Framework with Aptify are described in the following documents:

Configuring Logging Framework

This page details down the step-by-step instructions to configure Logging Framework implementation. 

Prerequisite

  • Aptify 6.2 or higher version up and running

Configuration Steps

By default, there is no setting present in the config file of applications for Smart Client, Aptify Web, and Async Processor. Thus, logging will be disabled.

<add key=" Aptify.Framework.LoggerFactory.isLoggingDisabled" value="false" />

Configuring logging framework with Smart Client, Aptify Web, and Async Processor

Please follow the below given configuration steps of the integration of the Logging framework with Aptify:

  1. Go to folder structure where Aptify is installed. (For example- C:\Program Files\Aptify 5.0)
  2. Search and open the appropriate config file for the application as shown below.

    Sr No Application File Name
    1 Smart Client

    AptifyShell.exe

    2 Aptify Web Web.Config
    3 Async Processor

    AptifyAsyncProcessor.exe

  3. Under <appSettings> section, add the below given keys.

    <add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
    <add key="serilog:write-to:RollingFile.pathFormat" value="Your local system path" />
    <add key="serilog:write-to:RollingFile.outputTemplate" value="
    [{Timestamp:hh:mm:ss}{Level:u3}] [UserCredentials: {UserContext}] [ClassName:{SourceContext}]{Message} {NewLine}{Exception}" />
    <add key="serilog:write-to:RollingFile.rollingInterval" value="Day" />
    <add key="serilog:write-to:RollingFile.rollOnFileSizeLimit" value="true" />
    <add key="serilog:write-to:RollingFile.shared" value="true" />
    <add key="serilog:minimum-level" value="Information" />
    <add key="Aptify.Framework.LoggerFactory.isLoggingDisabled" value="False" />

  4. Add file path as shown below, where the generated log file will be placed in the path format app setting of the config file.
    Name of app setting - "serilog:write-to:RollingFile.pathFormat" Value= “add file path here”
    For example – “c:\\foldername\\log.txt”
  5. Login to Application (Smart Client/Aptify Web/Async Processor).
  6. On successful login, verify firing of log user context event by checking the log file.
    In the log file, you can see the user credentials are logged with the correct user and check for other entity relation data like person, employee, or web user (if available).

Note

For getting error and process flow information to be logged in the log file instead of event viewer

You need to add following key in the exception management section of config files of different applications.

<publisher mode="on" days="3" assembly="AptifyExceptionManagement"
type="Aptify.Framework.ExceptionManagement.SerilogPublisher"/>

 

Verification steps:

  1. Login to Aptify application with valid user and update a person record.
  2. Check the log file in this case, the log file should have logged correct updated data with detailed actions.
  3. Try saving person record without adding data in one of the mandatory fields. Check the log file here if the log file is giving a valid error message and it is explanatory.

Sample log file generated for an entity action

Once you generate a log file for an entity action, you can see the below-given information:

  • Time Stand
  • User Credentials
  • Class Name
  • Source Contest

Different configuration options to turn logging On/Off for explicit entities and users

For integrating the Logging Framework, following are the configuration options using which we can turn logging on or off for explicit entities and users:

  1. The common thing that needs to be added to see logging on or off for explicit entities and users is,

    <add key="serilog:using:FilterExpressions" value="Serilog.Filters.Expressions" />

  2. To turn logging On/Off for explicit entities or classes,
    1. To turn On, add the following configuration keys,

      <add key="serilog:filter:ByIncluding.expression" value="SourceContext = 'GenericEntity'" />
      Where 'Generic entity' is just an example of a class name for which you want to see logging.

    2. To turn it Off, you just need to remove the above-mentioned configuration key from the file.
  3. Turn logging On/Off for explicit users,
    1. To turn On, add the following configuration keys,
      <add key="serilog:filter:ByIncluding.expression" value="UserName = 'TestUser'" />
      Where 'TestUser' is just an example of a username for which you want to see logging.
    2. To turn it Off, you just need to remove the above-mentioned configuration key from the file.

Customizing config options for Aptify specific items we put into the OutputTemplate

For customizing config options for Aptify specific items we put into the OutputTemplate, you can edit the below given configuration key in the file:

<add key="serilog:write-to:RollingFile.outputTemplate" value="[{Timestamp:hh:mm:ss}
{Level:u3}] [UserCredentials: {UserContext}] [ClassName:{SourceContext}] {Message}

 

List of Instrumented areas

The below list shows the different areas where we have instrumented logging Framework for Aptify:

  1. AptifyGenericEntity:
    Save InnerValidate FireEvent
  2. AptifySubtype.vb:
    DoSubtypeSave
  3. AptifyExceptionManagement:
    SerilogPublisher
  4. AptifyProcessFlowEngine:
    ExecuteProcessFlow
    ValidateExecutionRuleAndRun
  5. AptifyAsyncProcessor
  6. AptifyShell.vb
  7. SOADataServicesTokenValidation
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.