Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#NOISSUE] logging for batch exception #10354

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.navercorp.pinpoint.batch.common;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
Expand All @@ -27,6 +29,8 @@
*/
public class JobFailListener implements JobExecutionListener {

private static final Logger logger = LogManager.getLogger(JobFailListener.class);

private final JobFailMessageSender jobFailMessageSender;

public JobFailListener(Optional<JobFailMessageSender> jobFailMessageSender) {
Expand All @@ -40,6 +44,10 @@ public void beforeJob(JobExecution jobExecution) {
@Override
public void afterJob(JobExecution jobExecution) {
if (!jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) {
for (Throwable throwable : jobExecution.getAllFailureExceptions()) {
logger.error("job fail. exception message : " , throwable);
}

jobFailMessageSender.sendSMS(jobExecution);
jobFailMessageSender.sendEmail(jobExecution);
}
Expand Down