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

Notifications

Announcements

No record found.

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,390 Super User 2025 Season 2 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,390 Super User 2025 Season 2 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,390 Super User 2025 Season 2 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.
  • Community member 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans