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



enter image description here



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.



enter image description here










share|improve this question























  • 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














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



enter image description here



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.



enter image description here










share|improve this question























  • 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












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



enter image description here



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.



enter image description here










share|improve this question















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



enter image description here



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.



enter image description here







azure azure-functions azure-application-insights






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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












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.






share|improve this answer




















  • 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










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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

























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.






share|improve this answer




















  • 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














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.






share|improve this answer




















  • 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












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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế