Azure-docs: Error on Enable console logging

Created on 22 Aug 2018  Â·  7Comments  Â·  Source: MicrosoftDocs/azure-docs

When I was following this document got blow error on line "config.LoggerFactory = loggerFactory.AddConsole();" under section "Enable console logging"

_'JobHostConfiguration' does not contain a definition for 'LoggerFactory' and no extension method 'LoggerFactory' accepting a first argument of type 'JobHostConfiguration' could be found_

Looks like I am missing some reference.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;

namespace AzureJob
{
    // To learn more about Microsoft Azure WebJobs SDK, please see https://go.microsoft.com/fwlink/?LinkID=320976
    class Program
    {
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();

            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
            }

            config.DashboardConnectionString = "";
            var loggerFactory = new LoggerFactory();
            config.LoggerFactory = loggerFactory.AddConsole();

            var host = new JobHost(config);

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
    }
}

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

app-service-wesvc cxp in-progress product-question triaged

Most helpful comment

@BryanTrach-MSFT Upgrading to WebJobs 2.2.0 did the trick. Thanks!

All 7 comments

@ravick4u Thanks for your feedback! We will investigate and update as appropriate.

I have exactly the same problem after following the document guide

I had the same problem, and eventually realized it was because the Microsoft.Extensions.Logging package had failed to install. After changing the target framework to 4.6.1 and reinstalling the logging package, it worked as expected.

@ravick4u @Noissim I was able to work through the sample doc with no issues. I used 4.6.1 framework and made sure to use 2.2.0 version of webjobs.

It looks like @wjmoody03 was able to resolve the issue by ensuring he used similar versions. Can you please check this part of your projects?

@BryanTrach-MSFT Upgrading to WebJobs 2.2.0 did the trick. Thanks!

@ravick4u Since we have not heard back from you and we have three others verifying the resolution, we will proceed to close out this thread. If you have any further questions, please tag me in your reply.

@Noissim Great to hear. Thank you for updating us. Have a great weekend.

I had the same problem too. Followed below steps.

  1. changed the target framework to 4.6.1 and reinstalled all packages.
  2. Upgrading to WebJobs 2.2.0.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

varma31 picture varma31  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

monteledwards picture monteledwards  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

paulmarshall picture paulmarshall  Â·  3Comments