Subscribe for e-mails on certain application logs

To configure sending of emails from the application log you need component 6704 in your composition.

First of all you define your mail subscription via General Settings - Mail subscriptions


In my example I want to be informed about PrintNode errors

It is important that for you as a subscriber there is an email address defined in your connection information


Next step is to define one or more mail subscription data sources
Fill in the correct data source (that is used in the application log entries)
The from level and higher
The activity template
And the aggregate for number of hours

An example of the activity template to use

An example of the export definition

Another important setting is General settings - Mail subscription settings

In the mail subscription you can force sending of the e-mail by using the button ‘send mail now’
In the list of activities (Overviews - Activities) you can find your e-mail


And view the details sent by e-mail

Some extra information not mentioned yet
For the data source (AX Import in this example) it is important that it is ‘Active’ and that ‘Application log subscritions’ is set to Yes (only visible in change mode)

You need to have an ‘Activity template’ configured.
This activity template should have the setting Application - Mail subscription=yes)
It is important that Activity content is correct

This is the source code

Applicatielogs van %datetime% o.b.v. mailabonnementen

%applicationlogs%Log id Data source Created at Scheduled task Log message
%rows%%logid% %data_source% %logdate% %scheduled_task% %message%

 

The fields between %% in the Activity content should be defined in the Export definition (Activiteit applicationlogs)

It consists of 2 export datasets
1st: Activities

2nd Application logs
With the correct filter expression

boolean:and([
this.id.isgreater(int:max({applicationlogs,this.id}).sub(10000)),
this.data_source.in({
applicationlogsubscriptiondatasources,
this.data_source,
boolean:and([
this.mail_subscription.equals(parent.parent.application_log_subscription),
this.is_active.equals(yesno:load(1)),
this.is_for_apllication_log.equals(yesno:load(1)),
this.has_application_logs().equals(yesno:load(1))
])
}),
this.createdat.isgreaterequal(
datetime:first({
applicationlogsubscriptiondatasources,
this.last_activity_date_time(),
boolean:and([
this.data_source.equals(parent.data_source),
this.mail_subscription.equals(parent.parent.application_log_subscription)
])
}).expressiontoolsifnull(datetime:now())
),
this.log_type.id.islowerequal(
int:first({
applicationlogsubscriptiondatasources,
this.from_level_and_higher.id,
this.mail_subscription.equals(parent.parent.application_log_subscription)
})
)
])

Explanation
Only the last 10000 lines of the applicationlogs
With the datasource (AX import) Defined in the applicationlogsubscriptiondatasource (mail subscription source) from the applicationlogsubscription (mailsubscription)
For which the createdat is greater than last_activity_date_time
And with the desired severity level

It needs the following export data fields

In order to let this proces be called from the schedular add the following proces to the schedular
’Application log - send to subscribers’. This proces has one input parameter, the id of the mail subscrition

Hi Hans,

What is best-practice for having multiple mail subscriptions for different contacts and data sources? Say I want to send the printNode data source errors to person A and the financial data source errors to person B do I then make multiple mail subscriptions and multiple activity templates?

I tried this but I can only find one created activity template in this dropdown:

even though I have multiple templates with check set on ‘is for mail subscription’.

I have also tried to make multiple mail subscriptions attached to the same template but then it will only trigger on one data source. I am probably missing something, but don’t know what.

Kind regards,

Timothy

There is a problem in definiing multiple templates. I didn’t succeed myself either in selecting a copy of the activity template..
I asked the developer of this component for a solution.

So the only possibility by now seems to define another subscription with a different subscriber
And to define the financial application logs as the mail subscription data source.
By using the same activity template for e-mailing the results

1 Like

Thanks! For now I will try it that way then!