New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging written to the ILogger does not appear in the CLI #130

Closed
channeladam opened this Issue May 6, 2017 · 22 comments

Comments

Projects
None yet
@channeladam

channeladam commented May 6, 2017

Logging written to the ILogger does not appear in the CLI

@justinyoo

This comment has been minimized.

Show comment
Hide comment
@justinyoo

justinyoo Jun 15, 2017

Seems that it's still not fixed. Guess this ScriptHostHelper passes null, instead of ILogger instance.

https://github.com/Azure/azure-functions-cli/blob/master/src/Azure.Functions.Cli/Helpers/ScriptHostHelpers.cs#L24

@lindydonna Would you mind providing a rough timeline for this? I'm currently on beta.99.

justinyoo commented Jun 15, 2017

Seems that it's still not fixed. Guess this ScriptHostHelper passes null, instead of ILogger instance.

https://github.com/Azure/azure-functions-cli/blob/master/src/Azure.Functions.Cli/Helpers/ScriptHostHelpers.cs#L24

@lindydonna Would you mind providing a rough timeline for this? I'm currently on beta.99.

@pauldalyii

This comment has been minimized.

Show comment
Hide comment
@pauldalyii

pauldalyii Aug 22, 2017

I am running 1.0.2 and am still not seeing logs written to the CLI. Is this working for others yet? I'm running VS 15.3.1.

pauldalyii commented Aug 22, 2017

I am running 1.0.2 and am still not seeing logs written to the CLI. Is this working for others yet? I'm running VS 15.3.1.

@SteveALee

This comment has been minimized.

Show comment
Hide comment
@SteveALee

SteveALee Aug 22, 2017

Just in case it is at all related I regularly find the logging on Azure just stops, requiring a restart. I'm using javascript.

SteveALee commented Aug 22, 2017

Just in case it is at all related I regularly find the logging on Azure just stops, requiring a restart. I'm using javascript.

@alabaki

This comment has been minimized.

Show comment
Hide comment
@alabaki

alabaki Nov 6, 2017

Any news on this issue?

alabaki commented Nov 6, 2017

Any news on this issue?

@brentnewbury

This comment has been minimized.

Show comment
Hide comment
@brentnewbury

brentnewbury Dec 8, 2017

I'm getting a similar issue, no log entries for Microsoft.Extensions.Logging.ILogger are being output to the CLI nor the Portal.

brentnewbury commented Dec 8, 2017

I'm getting a similar issue, no log entries for Microsoft.Extensions.Logging.ILogger are being output to the CLI nor the Portal.

@slawlor

This comment has been minimized.

Show comment
Hide comment
@slawlor

slawlor Dec 18, 2017

Also experiencing this issue recently. I've been forced to revert to the TraceWriter until it's fixed

slawlor commented Dec 18, 2017

Also experiencing this issue recently. I've been forced to revert to the TraceWriter until it's fixed

@hoshauch

This comment has been minimized.

Show comment
Hide comment
@hoshauch

hoshauch Jan 3, 2018

We have the same problem, no log are shown in the azure-portal.

hoshauch commented Jan 3, 2018

We have the same problem, no log are shown in the azure-portal.

@MrGlenThomas

This comment has been minimized.

Show comment
Hide comment
@MrGlenThomas

MrGlenThomas Mar 7, 2018

I am using CLI 1.0.9 and it still does not work.

MrGlenThomas commented Mar 7, 2018

I am using CLI 1.0.9 and it still does not work.

@roryprimrose

This comment has been minimized.

Show comment
Hide comment
@roryprimrose

roryprimrose Mar 14, 2018

If I use TraceWriter, the entries are displayed in the console when debugging in VS2017. If I switch to ILogger, nothing is rendered to the console.

roryprimrose commented Mar 14, 2018

If I use TraceWriter, the entries are displayed in the console when debugging in VS2017. If I switch to ILogger, nothing is rendered to the console.

@johnib

This comment has been minimized.

Show comment
Hide comment
@johnib

johnib Mar 27, 2018

same for me as @roryprimrose says.

johnib commented Mar 27, 2018

same for me as @roryprimrose says.

@roryprimrose

This comment has been minimized.

Show comment
Hide comment
@roryprimrose

roryprimrose Mar 28, 2018

I'm now using an Autofac module to create ILogger instances using the LogFactory from an Azure functions context.

This doesn't log any messages to the console when debugging locally. Similarly, it also doesn't log to the log in the Azure portal. It does however log entries to Application Insights although it is difficult to get access to this data. The only way I've been able to do it so far is to run AI analysis queries over log data. I haven't been able to figure out a nice way of getting to the log data from the Azure portal itself.

roryprimrose commented Mar 28, 2018

I'm now using an Autofac module to create ILogger instances using the LogFactory from an Azure functions context.

This doesn't log any messages to the console when debugging locally. Similarly, it also doesn't log to the log in the Azure portal. It does however log entries to Application Insights although it is difficult to get access to this data. The only way I've been able to do it so far is to run AI analysis queries over log data. I haven't been able to figure out a nice way of getting to the log data from the Azure portal itself.

@MrGlenThomas

This comment has been minimized.

Show comment
Hide comment
@MrGlenThomas

MrGlenThomas Mar 28, 2018

@roryprimrose How do you access the logger factory from the azure function context? If I add an ILoggerFactory parameter to the Run method my function fails to run with a binding error. Only a parameter type of ILogger resolves an instance from the function host.

MrGlenThomas commented Mar 28, 2018

@roryprimrose How do you access the logger factory from the azure function context? If I add an ILoggerFactory parameter to the Run method my function fails to run with a binding error. Only a parameter type of ILogger resolves an instance from the function host.

@Mike-EEE

This comment has been minimized.

Show comment
Hide comment
@Mike-EEE

Mike-EEE Mar 30, 2018

Using 1.0.12... does the ILogger work at all? Is the guidance/expectation to use TraceWriter instead?

Mike-EEE commented Mar 30, 2018

Using 1.0.12... does the ILogger work at all? Is the guidance/expectation to use TraceWriter instead?

@roryprimrose

This comment has been minimized.

Show comment
Hide comment
@roryprimrose

roryprimrose Apr 6, 2018

@MrGlenThomas Sorry, took me a little while to get back to this. I've just posted about doing dependency injection with ILogger and ILogger<T> in Azure Functions. See https://www.neovolve.com/2018/04/05/dependency-injection-and-ilogger-in-azure-functions/

roryprimrose commented Apr 6, 2018

@MrGlenThomas Sorry, took me a little while to get back to this. I've just posted about doing dependency injection with ILogger and ILogger<T> in Azure Functions. See https://www.neovolve.com/2018/04/05/dependency-injection-and-ilogger-in-azure-functions/

@paulbatum

This comment has been minimized.

Show comment
Hide comment
@paulbatum

paulbatum Apr 12, 2018

Member

As far as I can tell this bug is fixed when running against functions V2 (beta). Still annoying for it to be busted for V1 though.

Member

paulbatum commented Apr 12, 2018

As far as I can tell this bug is fixed when running against functions V2 (beta). Still annoying for it to be busted for V1 though.

@brettsam

This comment has been minimized.

Show comment
Hide comment
@brettsam

brettsam Apr 16, 2018

Member

The fix for this is now merged in #437 and will be a part of the next CLI release.

Member

brettsam commented Apr 16, 2018

The fix for this is now merged in #437 and will be a part of the next CLI release.

@tourili

This comment has been minimized.

Show comment
Hide comment
@tourili

tourili May 22, 2018

I don't know if what I am experiencing is related to this issue:

  1. Create a webjob console project (using Microsoft.Azure.WebJobs 2.2.0)
  2. in my "function" I add ILogger parameter
  3. using that logger bunch of targets work well (Console file etc...) Except that nothing is written in the azure dashboard or kudu console.
    Looks like the TraceWriter is not involved at all when logging events using the ILogger parameter:
        [FunctionName("run-function")]
        public async Task RunAsync([QueueTrigger("request-run-function")] Section sectionRequest, ILogger logger, CancellationToken token)

Special Thanks for the help @brettsam @paulbatum

tourili commented May 22, 2018

I don't know if what I am experiencing is related to this issue:

  1. Create a webjob console project (using Microsoft.Azure.WebJobs 2.2.0)
  2. in my "function" I add ILogger parameter
  3. using that logger bunch of targets work well (Console file etc...) Except that nothing is written in the azure dashboard or kudu console.
    Looks like the TraceWriter is not involved at all when logging events using the ILogger parameter:
        [FunctionName("run-function")]
        public async Task RunAsync([QueueTrigger("request-run-function")] Section sectionRequest, ILogger logger, CancellationToken token)

Special Thanks for the help @brettsam @paulbatum

@brettsam

This comment has been minimized.

Show comment
Hide comment
@brettsam

brettsam May 23, 2018

Member

What version of the CLI are you using? 1.0.12 should have this fixed.

Member

brettsam commented May 23, 2018

What version of the CLI are you using? 1.0.12 should have this fixed.

@tourili

This comment has been minimized.

Show comment
Hide comment
@tourili

tourili May 23, 2018

I'm looking right on azure portal https://<web_app>/azurejobs/#/jobs/continuous/<webjob_name>. I'm not using CLI localy

tourili commented May 23, 2018

I'm looking right on azure portal https://<web_app>/azurejobs/#/jobs/continuous/<webjob_name>. I'm not using CLI localy

@brettsam

This comment has been minimized.

Show comment
Hide comment
@brettsam

brettsam May 23, 2018

Member

Oh sorry -- this issue is explicitly for the Functions CLI. I misread your comment. I've created a new issue here that we can follow-up on: Azure/azure-webjobs-sdk#1716

Member

brettsam commented May 23, 2018

Oh sorry -- this issue is explicitly for the Functions CLI. I misread your comment. I've created a new issue here that we can follow-up on: Azure/azure-webjobs-sdk#1716

@DocGreenRob

This comment has been minimized.

Show comment
Hide comment
@DocGreenRob

DocGreenRob Aug 22, 2018

I was able to use the ILogger from the Microsoft.Extensions.Logging library in my Azure Function project. However, when trying to do the same in my unittest project, which is using Moq I am unable to use it.

image

then, if I try Ctrl + . I get:
image

What am I doing wrong?

DocGreenRob commented Aug 22, 2018

I was able to use the ILogger from the Microsoft.Extensions.Logging library in my Azure Function project. However, when trying to do the same in my unittest project, which is using Moq I am unable to use it.

image

then, if I try Ctrl + . I get:
image

What am I doing wrong?

@paulbatum

This comment has been minimized.

Show comment
Hide comment
@paulbatum

paulbatum Aug 23, 2018

Member

I think either your unit test project is missing a reference to Microsoft.Extensions.Logging, or its hitting a naming conflict and you should try declaring the type with its fully qualified name Microsoft.Extensions.Logging.ILogger.

Member

paulbatum commented Aug 23, 2018

I think either your unit test project is missing a reference to Microsoft.Extensions.Logging, or its hitting a naming conflict and you should try declaring the type with its fully qualified name Microsoft.Extensions.Logging.ILogger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment