2

I have defined a logger as follows:

logger = logging.getLogger('APP')
syslog = logging.StreamHandler()
formatter = logging.Formatter('%(app_name)s : %(message)s')
app_name = {'app_name':'MULE'}
syslog.setFormatter(formatter)
logger.addHandler(syslog)
logger = logging.LoggerAdapter(logger, app_name)

I am trying to prepend a string to every logger message. I have added this code based on this question and other similar questions. The problem is that now the logger is printing out 2 statements for every output that I want. The output is as follows:

[03/Dec/2015 12:05:59] INFO views 91 1399960 [APP:1075] Picked
MULE : Picked

Why is this happening? Where am I going wrong?

Community
  • 1
  • 1
praxmon
  • 5,009
  • 22
  • 74
  • 121

0 Answers0