# Using ArEventLog Example Code for logging

**URL:** <https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617>\
**Category:** Programming\
**Created:** [October 18, 2024, 3:22am UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617 "2024-10-18T03:22:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [October 18, 2024, 3:22am UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617/1 "2024-10-18T03:22:21Z")

</div>

Hi,

I have created a ST program in Automation Studio and ported the example code for ArEventLog into it. The program is able to compile. I was wondering how I could modify this for logging a message from another .as or .st program. Is it possible to create a function that can be called from another automation basic program to perform logging? Would it be callable in C/C++ also?

When running the example program, should I see ‘This is an information entry from the user.’ log message?

Regards,  
Kenneth  
[Program.zip](https://community.br-automation.com/uploads/short-url/zb7AJlMAHwcOyPmxyjiksmqt2nt.zip) (4.2 KB)

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [October 18, 2024, 3:50am UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617/2 "2024-10-18T03:50:00Z")

</div>

I managed to display some logs from the same test program by setting the following in PROGRAM\_INIT:  
EventLog.Commands.CreateUserLog := TRUE;  
EventLog.Commands.WriteUserEvent := TRUE;

---

<div class="post-metadata">

**Author:** ![fabian.pries](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@fabian.pries](https://community.br-automation.com/u/fabian.pries)\
**Post date:** [October 18, 2024, 4:53am UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617/3 "2024-10-18T04:53:36Z")

</div>

Hello,

you can create a user library starting from this sample task.  
With a user library it would be possible to use the logging in every task you have.

Without a library you would need to create logbooks per task, share the ident for the logbook or acquire the ident using the name of logbook in each task.

I personally would go with the library option. The IEC conform library should be usable in IEC and also in a C/C++ program.

BR Fabian

---

<div class="post-metadata">

**Author:** ![fabian.pries](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@fabian.pries](https://community.br-automation.com/u/fabian.pries)\
**Post date:** [October 18, 2024, 4:54am UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617/4 "2024-10-18T04:54:55Z")

</div>

Kind of a duplicate ❓

> [@Using ArEventLog in Automation Basic](https://community.br-automation.com/t/using-areventlog-in-automation-basic/4586/10):
>
> If you created the ident in a C++ task, just copy the ident (which is the .ident output of the FB ArEventLogCreate, it’s an UDINT) on a global PLC variable, and use it for function block calls in the AB task. The 2nd possibility is to call the function block [ArEventLogGetIdent](https://help.br-automation.com/#/en/4/libraries%2Fareventlog%2Ffbks%2Fareventloggetident.html) in the AB task. This function block determines the ident by the given logger module name (which is a string). Then, there’s no need to share the ident out of the C++ program. Best regards!

---

<div class="post-metadata">

**Author:** ![marcusbnr](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/marcusbnr/32/256_2.png) [@marcusbnr](https://community.br-automation.com/u/marcusbnr)\
**Post date:** [October 18, 2024, 12:46pm UTC](https://community.br-automation.com/t/using-areventlog-example-code-for-logging/4617/5 "2024-10-18T12:46:49Z")

</div>

Closed on October 18, 2024, 12:46pm UTC

I’m closing this thread because it looks like a duplicate of the conversation in [another post](https://community.br-automation.com/t/using-areventlog-in-automation-basic/4586).
