severb / graypy

Python logging handler for Graylog that sends messages in GELF (Graylog Extended Log Format).
https://www.graylog.org/
BSD 3-Clause "New" or "Revised" License
258 stars 90 forks source link

single message received multiple times by graylog #142

Closed BeeStingBob closed 1 year ago

BeeStingBob commented 1 year ago

I'm getting behaviour where I send one message but graylog receives multiple, and the number received by graylog can incrementally increase with each message sent. Example, each blue bar should be one message.

cropped

initialised with

class BehaveLogger():

    def __init__(self):
        self.logger = logging.getLogger(FACILITY)
        self.logger.setLevel(logging.INFO)
        handler = graypy.GELFUDPHandler(self.host, self.port, debugging_fields=True)
        self.logger.addHandler(handler)
        self.adapter = logging.LoggerAdapter(logging.getLogger(FACILITY),
                                             {'Project_ID': PROJECT_ID,
                                              'Job_Name': JOB_NAME,
                                              })  
    def log_generic(self, doc):
                self.adapter.info(json.dumps(doc))

called with

from grayloglogger.grayloglogger import BehaveLogger

self.logger = BehaveLogger() 

for job_trace in job_traces():
    self.logger.log_generic(job_trace)

any thoughts would be appreciated?

BeeStingBob commented 1 year ago

looks like I might have been adding extra handlers .... https://stackoverflow.com/questions/37134573/python-logging-duplicates-the-log-messages