I am trying Python logging.
Since I want some logger to share a formatter, I use hierarchy of logging like the below code.
As you can see, format is '%(asctime)s - %(name)s - %(message)s'
At this point, I want loggers to print the %(name)s
part without the parent name.
I mean, normally it will print the name as 'SYS.Start Up Routine'
but I want 'Start Up Routine'
Is there any way?
logging.root.level = logging.DEBUG
logger = logging.getLogger('SYS')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(message)s')
streamHandler = logging.StreamHandler()
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)
logger1 = logging.getLogger("SYS.Start Up Routine")
logger2 = logging.getLogger("SYS.Message Layer")
logger3 = logging.getLogger("SYS.Application Layer")