Qlik Community

Qlik Architecture Deep Dive Blog

Deep dives into specific back-end technologies which allow for the extension of Qlik to fit the needs of the enterprise.

Employee
Employee

Using Apache Log4Net to receive email notification for reload failures

This is a more in-depth post as a follow up to the overview post: Getting Notified from Qlik Sense

smtp appender

The smtp appender is an appender type provided by the Apache Log4Net library which Qlik Sense uses. At its core, the configuration of this appender will require:

  • smtp server details
  • A logger from Qlik Sense to attach in order to trigger email alerts

The smtp server configuration can vary between email providers, but examples are provide in this Github Repository.

For the logger details, an excerpted config may look as follows:

...
        <layout type="log4net.Layout.PatternLayout">
            <param name="conversionPattern" value="Date: %date %newlineTask Name: %property{TaskName}%newlineAppName:%property{AppName}%newlineError Message: %message%newline%newline%newline" />
...
    <logger name="System.Scheduler.Scheduler.Slave.Tasks.ReloadTask">
        <appender-ref ref="MailAppender" />
    </logger>

...

To explain the mapping refer to this Qlik Sense Scheduler log:

scheduler-log.png

 

In the <layout> tag, we are using % to provide variables which are taken from the header of the log file

XML Element Sense Log / Cell Value
<layout> %property{TaskName} M1
<layout> %property{AppName} Q1
<logger> E6

An example email alert from using this method:

notified_2.png

 

17 Comments
New Contributor III

Hi Levi,

thansk for sharing this article.

we have placed this file LocalLogConfig.xml file in the below path.

To configure Qlik Sense to use an appender, a configuration file, LocalLogConfig.xml must be created in the %ProgramData%\Qlik\Sense\<service> folder.

we have placed this file in the proxy node.

do we need to do any other configuration and we want to know how to test this activity.

Regards,

balaji

0 Likes
1,129 Views
Employee
Employee

@balaji_MAC : I do not follow. What are  you trying to use Log4Net for?

Broadly the steps are:

  • Place the XML into the service directory for the service who does the logging that you're interested in
  • Ensure that the XML has appropriate authentication settings
  • Figure out which logger you want to monitor
  • Success

Practically, I like to test Log4Net using the UDP appender since it will go locally to a module that I am running.

0 Likes
1,116 Views
New Contributor III

Hi Levi,

Hope you are doing well.

Apologies for the delay.

i tried to implement this solution but i couldn't able to achieve it.

do we any document or gudiance to implement this solution.

i have few open questions.

Current issue:

1.Do we need to install log4net or any other configration?

2.we couldn't able to find below path in our Qlik environement.

LocalLogConfig.xmlLog4Net\udp\qpsLog4Net udp Appender for notification of Qlik Sense Proxy Sessions
LocalLogConfig.xmlLog4Net\udp\qssLog4Net udp Appender for notification of email failures

 

3.we are in the process to implement qlik task failure auto email notifcation.

Thanks in advance.

Regards,

Balaji

0 Likes
1,086 Views
New Contributor III

Hi Levi,

Hope you are doing well.

Can you please let us know yoru input on the above request.

Regards,

balaji

0 Likes
1,076 Views
Employee
Employee

> Do we need to install log4net or any other configration?

No. Just place a properly configured XML file into the appropriate service directory (%ProgramData%\Qlik\Sense\<Service>, e.g. %ProgramData%\Qlik\Sense\Scheduler).

 

> 2.we couldn't able to find below path in our Qlik environement.

Those are just the structure of how I stored things in GitHub, see above.

1,052 Views
New Contributor III

Hi Levi,

Thanks for your update.

we have placed file in the right path and reloaded Qlik task but we didn't get any email notification.

Do we need to do any other configuration to get task failure notification.

https://www.youtube.com/watch?v=dnDqzN8pj70

i have gone through above video and you ran some node js.Kindly guide us to implement this solution.

Appreciate you support.

Regards,

Balaji

0 Likes
1,041 Views
Employee
Employee

> Do we need to do any other configuration to get task failure notification.

You would need to:

  • Have the XML file deployed to the Central node
  • Specify valid authentication parameters for your email server
    • Let's take the example for Office 365
      • You'd need to:
        • Enter a valid to param
        • Enter a valid from param
        • Ensure port 587 is accessible at smtp.office365.com from the server (e.g. PowerShell > Test-NetConnection -Host smtp.office365.com -Port 587
        • Enter a valid username param
        • Enter a valid password param
1,033 Views
New Contributor III

Hi Levi,

Appreciate it.

Thank you so much.it is working as expected.

Can we change font size of the email content and is it possible to attach logs.

Thanks in advance

Regards,

Balaji

0 Likes
1,026 Views
Employee
Employee

Unfortunately, no. The email is raw text. On the upside, it's easy to implement and free. For more sophisticated examples you'd want to have some other system generate the email. Whether it's a system running UDP or listening for a Notification push (described in other posts). Or a partner created tool like https://www.pingalerting.com/.

1,017 Views
New Contributor III

Hi Levi,

Thank you so much for your kind support.

we will explore pingalerting from our end.

Regards,

balaji

0 Likes
1,006 Views
New Contributor III

Hi Levi,

Hope you are doing well.Can we change email content in the alert?

Please refer below sample alert email content.

Date: 2019-08-23 05:06:14,741

 Task Name: Reload task of Vehicle Sales

 AppName Vehicle Sales

 Error Message: Message from ReloadProvider: Reload failed in Engine. Check engine or script logs.

we want to remove strikethrough content from email.

Error Message: Message from ReloadProvider: Reload failed in Engine. Check engine or script logs

i know alerts are triggered based on Qlik event using log4net.

let us know your input on this.

Appreciate your support.

Regards,

Balaji

0 Likes
953 Views
Employee
Employee

It may be possible, but I am not aware of a method.

0 Likes
942 Views
New Contributor III

Hello,

 

Would it be possible to attach log file with this alert email for reload failures.. 

 

Cheers,

RK.

0 Likes
891 Views
Employee
Employee

@rkondaveti : I am not aware of a way using this method for attaching a log file.

0 Likes
872 Views
New Contributor III

@Levi_Turner  : Thank you. Is there any other way to attach log file, the main problem is for us to identify the relevant log file  for a task 

 

Cheers,

Raghav.

0 Likes
858 Views
Employee
Employee

@rkondaveti : Using an approach like the Notification API and building your own service would do it since the Task Log is exposed via the QRS API. This would obviously require some development effort.

0 Likes
849 Views
New Contributor

Hi Levi, 

I would like to add Task name in the email subject.

Do know how to add"Task Name: %property{TaskName}%"  in the subject field?

Thanks! this is really useful. 

 

 

0 Likes
704 Views