You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

About

In this page, it is described how to add theproject to your solution and how to use the functionality in it.

Adding the project to your solution

To use the project functionality, you need to first add the library to your solution. 
It is done in Visual Studio by following those steps:

  1. Right click the solution explorer on the top level solution
  2. Choose Add→Existing project
  3. Navigate to EGU.PartnerPortal.Shared project
  4. Double click the csproj file
  5. Now add the project reference inside your project
  6. Right click the solution explorer in Dependencies→Projects→Add Project Reference
  7. Add a tag in teh shared project:

The project is now ready for use.

Using the Logging

Hosting environment

The way the logging work is, that it checks an environment setting on the application level in the hosting weather or not to log.

Therefore, it is important that you setup the following variables:

  • LOGSTATE
    • TRUE
      The logger will create a log entry
    • FALSE
      The logger will not create any logs at all
  • APP_INSIGHT_KEY
    • Containing the insight key that can be found on the appinsight app hosting page on Azure.

To set the variables one should do the following:

  1. Go to the application hosting where you have implemented logging.
  2. Click on Containers in the left most menu
  3. In the middle of the screen click 'Environment Variables'
  4. Add the variables
  5. Click 'Save as new revision'

The application will restart and is now ready for use.

Code

The Logging functionality can be accessed from the static class simply called Log.cs. 

Before being able to log through the project you need to initialize the logger. (Should always be done when your application starts up, and is only done ones) 

Initializing is done in this way: 

Logger initialization
string invoker = "IntegrationApi"; 									    /*The name of the application using the log*/

Log.Initialize(invoker); 												/*Initializing the logger, making it ready for use*/
Log.LogInfo("Integration api started.");								/*Initial message showing that teh logging and application have started*/
Log.LogInfo("Logger running");											

When wanting to create a logentry do the following in the code:

Create log entry
/*The logger have the following options:*/
Log.LogInfo("This is an info message");
Log.LogDebug("This is a debug message");
Log.LogWarn("This is a warning message");

Log.LogException(new Exception("This is an exception message"));

Having logged in this way will make the messages appear in the application insights logs. 

On how to view those, view the documentation for the integration service.

Other functionality

Global Enums

In here , you can store the enums that are to be used throughout the systems.

EnvConf

Use this class to get environment variables from Azure.

The methods provide options for getting various types of data.

DTOs folder

This folder is reserved for DTO entities. 
Please keep a good order and follow the guidelines for putting them here:

  • Add a top level folder under the 'DTO' folder
  • Name the sub folder a descriptive thing according to where the DTOs are used
  • Put the DTOs in the folder



  • No labels