Skip to content

TCP logging on FluentBit from Python #5823

Answered by goatwu1993
msSarriman asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for this thread. Turns out logging.handlers.SockeHandler pickles the message before sending in the emit method for some reason. Remove the pickles will work.

Here's a handler which works

from logging.handlers import SocketHandler

class FluentBitHandler(SocketHandler):
    def emit(self, record):
        try:
            self.send((self.format(record)).encode())
        except Exception:
            self.handleError(record)

Of source you need to make sure the format is JSON.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@cosmo0920
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by patrick-stephens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants