Forum Discussion
Missing Operation ID and name
We'd like to customize out log format, so we have a method to get the logger.
However, when we use the logger, we found that the operation_Name and operation_Id disappeared. We'd like to know why the operation_Name and operation_Id disappear and how to make it show on the query result.
Here' the sample code to get logger:
FORMAT = json.dumps(
{ 'loggerName': '%(name)s',
'funcName': '%(funcName)s',
'message': '%(message)s',
'asctime': '%(asctime)s',
'level': '%(levelname)s', } )
def get_customized_json_logger(logger_name):
logger = logging.getLogger(logger_name)
logger.setLevel(logging.INFO)
log_handler = logging.StreamHandler()
log_handler.setLevel(logging.INFO)
formatter = logging.Formatter(FORMAT)
log_handler.setFormatter(formatter) logger.addHandler(log_handler) return logger
1 Reply
The disappearance of operation_Name and operation_Id in Application Insights traces is caused by how telemetry correlation works, fields are only populated when logs are emitted within a valid request/activity context. For custom logger without binding to the current Activity or TelemetryClient, the correlation metadata is lost, learn.microsoft.com/en-us/azure/azure-monitor/app/data-model-complete