Last active
November 22, 2020 03:47
-
-
Save rchardptrsn/7b355e431d007c744499133ad6302e20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from opencensus.ext.azure.log_exporter import AzureLogHandler | |
| # function to initialize App Insights logger object | |
| def startLogger(): | |
| from opencensus.ext.azure.log_exporter import AzureLogHandler | |
| # Get Azure Monitor instrumentation key from environment variable | |
| instrumentation_key = os.environ.get('InstrumentationKey') | |
| # initialize logger object | |
| logger = logging.getLogger(__name__) | |
| # define connection string attribute of logger object | |
| # this uses our Azure Monitor instrumentation key | |
| logger.addHandler(AzureLogHandler( | |
| # connection_string='InstrumentationKey=<your-key-here' | |
| connection_string=instrumentation_key | |
| )) | |
| return logger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment