Skip to content

Commit ee0abe7

Browse files
committed
logs
1 parent 26a5c24 commit ee0abe7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

articles/azure-monitor/app/asp-net-trace-logs.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ ms.date: 05/08/2019
1515
ms.author: mbullwin
1616

1717
---
18-
# Explore .NET/.NET Core trace logs in Application Insights
18+
# Explore .NET/.NET Core and Python trace logs in Application Insights
1919

20-
Send diagnostic tracing logs for your ASP.NET/ASP.NET Core application from ILogger, NLog, log4Net, or System.Diagnostics.Trace to [Azure Application Insights][start]. You can then explore and search them. Those logs are merged with the other log files from your application, so you can identify traces that are associated with each user request and correlate them with other events and exception reports.
20+
Send diagnostic tracing logs for your ASP.NET/ASP.NET Core application from ILogger, NLog, log4Net, or System.Diagnostics.Trace to [Azure Application Insights][start]. For Python applications, send diagnostic tracing logs using AzureLogHandler in OpenCensus Python for Azure Monitor. You can then explore and search them. Those logs are merged with the other log files from your application, so you can identify traces that are associated with each user request and correlate them with other events and exception reports.
2121

2222
> [!NOTE]
2323
> Do you need the log-capture module? It's a useful adapter for third-party loggers. But if you aren't already using NLog, log4Net, or System.Diagnostics.Trace, consider just calling [**Application Insights TrackTrace()**](../../azure-monitor/app/api-custom-events-metrics.md#tracktrace) directly.
@@ -152,6 +152,23 @@ You can also add a severity level to your message. And, like other telemetry, yo
152152

153153
This would enable you to easily filter out in [Search][diagnostic] all the messages of a particular severity level that relate to a particular database.
154154

155+
## AzureLogHandler for OpenCensus Python
156+
The Azure Monitor Log Handler allows you to export Python logs to Azure Monitor.
157+
158+
Instrument your application with the [OpenCensus Python SDK](../../azure-monitor/app/opencensus-python.md) for Azure Monitor.
159+
160+
This example shows how to send a warning level log to Azure Monitor.
161+
162+
```python
163+
import logging
164+
165+
from opencensus.ext.azure.log_exporter import AzureLogHandler
166+
167+
logger = logging.getLogger(__name__)
168+
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>'))
169+
logger.warning('Hello, World!')
170+
```
171+
155172
## Explore your logs
156173
Run your app in debug mode or deploy it live.
157174

0 commit comments

Comments
 (0)