-
Notifications
You must be signed in to change notification settings - Fork 165
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
Simplify setting up the NLog config #184
Comments
Proposal, is this easy enough? This uses the "UseNLog" pattern. public class Program
{
public static void Main(string[] args)
{
// NLog: setup the logger first to catch all errors
LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");
var logger = LogManager.GetCurrentClassLogger();
try
{
BuildWebHost(args).Run();
}
catch (Exception e)
{
//NLog: catch setup errors
logger.Error(e, "Stopped program because of exception");
throw;
}
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args) //note: this also adds the default MS loggers
.UseStartup<Startup>()
.UseNLog() // NLog: setup NLog for Dependency injection
.Build();
} @grokky1, @snakefoot please your opinion, thanks! |
i'm doubting to create a helper for LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");
var logger = LogManager.GetCurrentClassLogger(); e.g. replace it with var logger = NLogAspNetCore.InitLogger("NLog.config"); But maybe it's needed (for #187 at least) |
Core2 is much simpler than before, but honestly, some stuff is still confusing, and there's too many places to tweak to get stuff done. So, I like your convenience functions ( As far as your comment |
@grokky1 thanks for the info
Thanks! Needed that info :) If have now (locally) |
Pity we can't use But I suppose it's fine. In truth we will only use it once in the app's lifecycle. |
fixed by #191 |
Simplify setting up NLog for ASP.NET Core 2
Currently setting up takes a lot of steps. It should be as easy as possible - but also flexible enough. Also the current design not really suitable for ASP.NET Core 2
Current config (code set-up only):
Redesign the API design for ASP.NET Core 2
(maybe also replace
ConfigureNLog(this IHostingEnvironment env
)The text was updated successfully, but these errors were encountered: