Press enter to see results or esc to cancel.

How to use Integration Manager’s log4net log appender

This blog post describes one of the ways/functions we offer to log events/message to Integration Manager by using Integration Manager’s log appender for Log4Net. We assume that you have basic knowledge in Log4Net as well as you have a running instance of Integration Manager. Before continuing reading, make sure you have the correct link to Integration Manager’s Log API. In my exampel the test application and Integration Manager are located on the same server and the address to LogAPI is “http://localhost/IM/LogApi/LogApiService.svc“.

We will work with an example solution – a simple console application that prompts the user to enter a message which will log the message to a file with Log4Net’s file appender. During this how-to we will show you how you can extend your application with Integration Manager’s Log4Net appender. You can download the example here.

Before we start we let us take a look at how the application works.

  1. Start the application
    Console Application - Image 1
  2. Write a message to log – Hello World
    Console Application - Image 2
  3. The application will write into a file called tutorial.log in the application’s folder.
    Console Application - Image 3
  4. The result
    Console Application - Image 4

Let’s start adding Integration Manager’s log appender for Log4Net. We start by downloading the appender here.

The file you downloaded contains readme and DLL files. Start by copying the DLL files from the downloaded ZIP into the applications folder and open your applications configuration file which in the example looks like the code below.

Since we log a message to Integration Manager’s Log API we need to add the required “ServiceModel” configuration – see below.

Copy the above code, replace client/endpoint/@address value “http://localhost/IM/LogAPI/LogApiService.svc” with the address of your Integration Manager’s Log API instance and paste it into the application’s configuration file.

The next step is to add an application settings key called “IM.Log4Net.IsOneWay” which is of type boolean – set it depending on the requirements to either true or false.

If the application setting “IM.Log4Net.IsOneWay” is set to true the application will not ensure deliverance to the Log API, since we have configured the (IM) appender for Log4Net to not wait for a response (one way).

For log4net to understand that it needs to log an event/message with the provided appender you need to extend the configuration file with a reference to the appender as well as an appender configuration (IMAppender) – see below.

All the parameters used in the (IMAppender) appender configuration file are described in the readme.pdf that comes with the appender you downloaded before.

When the configuration is completed you can then start the application, write a text message and press Enter. The application will then log the event/message via the IM appender to Integration Manager – the configured Log Agent, End Point and Message Type will automatically added to Integration Manager. You can then create a log views allowing users to only search for events/messages coming from applications that use this (IM) appender.

You can see an example search result of Integration Manager in the screenshot below.

Console Application - Image 6

 

You can download the final application here. We hope that this blog post gets you started with logging your Log4Net logs to Integration Manager, giving you yet another way to log messages to Integration Manager for a centralized platform for all your logs, no matter what integration platform, application nor technology you use.