web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Create log to a custom batch job x++

(1) ShareShare
ReportReport
Posted on by 163
I create a new batch job that inserted lines in serviceOrderLine table I need to create log in this batch that display how many records did insert and update 
how can I create this log ?
I have the same question (0)
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
    Hi @Menna,

    You must add a info message in your batch job code.

    and then you can go to the batch job history page 

    finally you'll find the logs

    Best regards,
    Mohamed Amine MAHMOUDI
    ​​​​​​​
  • Menna Allah Ahmed Profile Picture
    163 on at
    I did it , I added Info message in run method but when I tried to open log tab I got this error 
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
    Hi @Menna,
     
    I think you have issue in your code in batch job class.
    I suggest you debug with batch.exe
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Menna Allah Ahmed Profile Picture
    163 on at
    Thanks Mohammed it works 
  • Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
    Hi @Menna,
     
    if it helps you please mark the answer verified.
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    You need two variables of int type and for every update or insert you need to append for these 2 variables and show that as an info.
  • CU27040844-17 Profile Picture
    2 on at

    To create a log for the batch job detailing the number of records inserted and updated in the serviceOrderLine table, a smart and organic approach involves integrating logging functionality within the batch job's codebase. This can be achieved by implementing a robust logging system that captures relevant information and provides insightful feedback to stakeholders. Begin by initializing counters to track the number of records inserted and updated. As the batch job executes, increment these counters accordingly for each insertion and update operation. Additionally, incorporate error handling mechanisms to gracefully manage any unexpected issues that may arise during the process, ensuring thorough logging of errors alongside affected records. At the completion of the batch job, generate a comprehensive log entry that includes the total counts of inserted and updated records, along with pertinent metadata such as timestamps for reference. Format the log output in a clear and concise manner, optimizing readability for stakeholders. Prior to deployment, rigorously test the logging functionality to validate its accuracy and reliability, thereby ensuring that the log effectively communicates the outcomes of the batch job execution to stakeholders in a meaningful manner.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 608

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 591 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans