Application Insight TelemetryClient doesn't display logs in Azure Function Console
up vote
0
down vote
favorite
I implemented TelemetryClient to sink application logs into Application Insight. Below is my implementation
public class Log : ILog
private static TelemetryClient telemetryClient = new TelemetryClient() InstrumentationKey = ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"] ;
public void Error(string message, Exception ex = null)
telemetryClient.TrackTrace(message, SeverityLevel.Error);
if (ex != null)
telemetryClient.TrackException(ex);
public void Info(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Information);
public void Verbose(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Verbose);
public void Warning(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Warning);
public TelemetryClient TelemetryClient
get
return telemetryClient;
I could see all custom logs in ApplicationInsight
Problem
When I want to do live monitoring, I could not see custom logs in Azure function logs window, function display below log which I'm not writing.
azure azure-functions azure-application-insights
add a comment |
up vote
0
down vote
favorite
I implemented TelemetryClient to sink application logs into Application Insight. Below is my implementation
public class Log : ILog
private static TelemetryClient telemetryClient = new TelemetryClient() InstrumentationKey = ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"] ;
public void Error(string message, Exception ex = null)
telemetryClient.TrackTrace(message, SeverityLevel.Error);
if (ex != null)
telemetryClient.TrackException(ex);
public void Info(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Information);
public void Verbose(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Verbose);
public void Warning(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Warning);
public TelemetryClient TelemetryClient
get
return telemetryClient;
I could see all custom logs in ApplicationInsight
Problem
When I want to do live monitoring, I could not see custom logs in Azure function logs window, function display below log which I'm not writing.
azure azure-functions azure-application-insights
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I implemented TelemetryClient to sink application logs into Application Insight. Below is my implementation
public class Log : ILog
private static TelemetryClient telemetryClient = new TelemetryClient() InstrumentationKey = ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"] ;
public void Error(string message, Exception ex = null)
telemetryClient.TrackTrace(message, SeverityLevel.Error);
if (ex != null)
telemetryClient.TrackException(ex);
public void Info(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Information);
public void Verbose(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Verbose);
public void Warning(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Warning);
public TelemetryClient TelemetryClient
get
return telemetryClient;
I could see all custom logs in ApplicationInsight
Problem
When I want to do live monitoring, I could not see custom logs in Azure function logs window, function display below log which I'm not writing.
azure azure-functions azure-application-insights
I implemented TelemetryClient to sink application logs into Application Insight. Below is my implementation
public class Log : ILog
private static TelemetryClient telemetryClient = new TelemetryClient() InstrumentationKey = ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"] ;
public void Error(string message, Exception ex = null)
telemetryClient.TrackTrace(message, SeverityLevel.Error);
if (ex != null)
telemetryClient.TrackException(ex);
public void Info(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Information);
public void Verbose(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Verbose);
public void Warning(string message)
telemetryClient.TrackTrace(message, SeverityLevel.Warning);
public TelemetryClient TelemetryClient
get
return telemetryClient;
I could see all custom logs in ApplicationInsight
Problem
When I want to do live monitoring, I could not see custom logs in Azure function logs window, function display below log which I'm not writing.
azure azure-functions azure-application-insights
azure azure-functions azure-application-insights
edited Nov 9 at 10:15
asked Nov 8 at 15:10
Pankaj Rawat
416517
416517
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05
add a comment |
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It's expected. The Azure function logs window you mentioned shows logs written in functions by TraceWriter
or ILogger
, including those logs created by function runtime, i.e. the function execution results you saw.
Using this Track* method, telemetryClient sends telemetries for display in Diagnostic Search, which are not available in function log streaming.
If you want see those Track* in function logs, output them using TraceWriter
or ILogger
(recommended) and configure log level in host.json.
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It's expected. The Azure function logs window you mentioned shows logs written in functions by TraceWriter
or ILogger
, including those logs created by function runtime, i.e. the function execution results you saw.
Using this Track* method, telemetryClient sends telemetries for display in Diagnostic Search, which are not available in function log streaming.
If you want see those Track* in function logs, output them using TraceWriter
or ILogger
(recommended) and configure log level in host.json.
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
add a comment |
up vote
0
down vote
It's expected. The Azure function logs window you mentioned shows logs written in functions by TraceWriter
or ILogger
, including those logs created by function runtime, i.e. the function execution results you saw.
Using this Track* method, telemetryClient sends telemetries for display in Diagnostic Search, which are not available in function log streaming.
If you want see those Track* in function logs, output them using TraceWriter
or ILogger
(recommended) and configure log level in host.json.
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
add a comment |
up vote
0
down vote
up vote
0
down vote
It's expected. The Azure function logs window you mentioned shows logs written in functions by TraceWriter
or ILogger
, including those logs created by function runtime, i.e. the function execution results you saw.
Using this Track* method, telemetryClient sends telemetries for display in Diagnostic Search, which are not available in function log streaming.
If you want see those Track* in function logs, output them using TraceWriter
or ILogger
(recommended) and configure log level in host.json.
It's expected. The Azure function logs window you mentioned shows logs written in functions by TraceWriter
or ILogger
, including those logs created by function runtime, i.e. the function execution results you saw.
Using this Track* method, telemetryClient sends telemetries for display in Diagnostic Search, which are not available in function log streaming.
If you want see those Track* in function logs, output them using TraceWriter
or ILogger
(recommended) and configure log level in host.json.
answered Nov 12 at 8:30
Jerry Liu
6,8431327
6,8431327
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
add a comment |
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
Primarily I have Azure function app with multiple layers (service layer, data access layer etc.), where I injected my ILog interface, it helps me to write a unit test with Mock.
– Pankaj Rawat
Nov 12 at 9:59
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
How I can resolve ILogger using Dependency Injection any example?? Azure function will auto resolved when it will trigger, but I'm not sure how I will resolve in other layers.
– Pankaj Rawat
Nov 12 at 10:04
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53210589%2fapplication-insight-telemetryclient-doesnt-display-logs-in-azure-function-conso%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you please provide some more details? is it a v1 function app? and where is the ILog from(or which assembly should I reference)? what's your code in the Run() method?
– Ivan Yang
Nov 12 at 8:27
using v1 function app. ILog is my own interface, which I'm injecting using [Inject] attribute in function app and other places. I want to write unit test with Mock that is why I implemented my own Logger.
– Pankaj Rawat
Nov 12 at 9:54
You can refer to jerry's answer below, see if it's the situation.
– Ivan Yang
Nov 12 at 9:59
not sure how I will resolve ILogger using DI.
– Pankaj Rawat
Nov 12 at 10:05