AWS Glue Job does not log information messages in the output file

0

Hi,

I was using AWS Glue job with Python shell. The log.info() messages does not log in the output log file instead it logs in the error.log file.

Here is the snippet we use to log messages in the glue job

we define logger as below code snippet: def logger_setup(self): self.logger = logging.getLogger(name) self.logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') console_handler = logging.StreamHandler() console_handler.setLevel(logging.INFO) console_handler.setFormatter(formatter) self.logger.addHandler(console_handler)

However when we used in the main file, logger.info(f"first day of month for this job {self.first_day_of_month}") This message logs in the Error logs instead Output logs. I want to post info messages in the Output logs. Can you tell me how we can achieve this? Is there any documentation available in logging messages in Glue job Python Shell

Chandra
gefragt vor 7 Monaten382 Aufrufe
2 Antworten
0

Could you please try with the following piece of code:

self.logger.setLevel(logging.DEBUG) ... console_handler = logging.StreamHandler(sys.stdout) console_handler.setLevel(logging.DEBUG)

Thank you :)

beantwortet vor 7 Monaten
0

I tried this with sys.stdout. But this print all the log levels on both output log and error log. I want to print logger.info() into output log and logger.error() in error log. Is there a way to print that?

Chandra
beantwortet vor 7 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen