Skip to content
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

NLog Extension not working for 4.5.1 or 4.6.1 frameworks #40

Closed
koocbor opened this issue May 27, 2016 · 7 comments
Closed

NLog Extension not working for 4.5.1 or 4.6.1 frameworks #40

koocbor opened this issue May 27, 2016 · 7 comments
Assignees
Labels

Comments

@koocbor
Copy link

koocbor commented May 27, 2016

Is there a plan to get the NLog extension working if you are targeting the 4.5.1 or 4.6.1 frameworks?

Taking the example application the logging works - but if I change the project.json file to the following no logging is done:

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics":  "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "NLog.Extensions.Logging": "1.0.0-rc2-final-2016-05-21"

  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.Web": "4.0.0.0"
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
@304NotModified
Copy link
Member

It's a bit difficult as we don't know if you're using aspnet core or aspnet 4.5 if you are using net451. We I guess the problem is in finding NLog.Config. Could you tests with

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      //add NLog to aspnet5
      loggerFactory.AddNLog();

      //configure nlog.config in your project root
      env.ConfigureNLog("nlog.config");

@koocbor
Copy link
Author

koocbor commented May 27, 2016

@304NotModified - Thanks - that worked. Appreciate the quick response.

@304NotModified
Copy link
Member

Thanks for the feedback!

I think this library should inject some behavior into NLog, so we know it's .NET Core

@Srikanthreddy2605
Copy link

I am Getting Following error and application getting stopped automatically

Using Asp.Net core

SYSTEM.TYPEINTIALLIZATIONException in Micorsoft.AspNetCore.Server.Kestrel.dll

@304NotModified
Copy link
Member

That's an unexpected error. Would try to look at this, this week

@304NotModified
Copy link
Member

@Srikanthreddy2605

Cannot reproduce your error. I added an example for NET 4.6.1: #56

This issue is solved, I have created a new issue for the env.ConfigureNLog("nlog.config"); and will close this one.

@304NotModified
Copy link
Member

related #91 . Fixed in beta3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants