-
Notifications
You must be signed in to change notification settings - Fork 58
Publishing default ASP.Net Core Web app template to azure doesn't modify the log location in web.config, resulting in no logs being produced #540 #167
Comments
@moozzyk is the change in publish-iis command or the templates? @Eilon @DamianEdwards do we want to fix this for RC2? |
I don't think it can be done in templates (or only in templates). When the application is being created you don't know whether it's going to be published for Azure or IIS. When publish-iis is invoked we know if we are publishing for Azure or not. This is when we have a chance to react. The question is how we should know whether to react. One option is to not put stdoutPath to the web.config by default (this would requires changes in templates) at all. In this case publish-iis will set the path accordingly. Another way is just to leave the templates alone as today and have publish-iis check the value - if the stdoutPath has the default value it would be overwritten otherwise it would be not touched to not overwrite something the user set. In this case the changes are needed only in publish-iis tool. |
The other alternative is to have the templates set the log path to %LOG_PATH% like we do for the app and args. Then it publish-iis could check for this default and replace it for normal or azure publish. |
If we can make a very simple fix (aka extremely-low-risk) to the templates ASAP then I'm OK with this for RC2. Otherwise, we should revisit this in RTM. |
Today, when git deploying an app to Azure, you end up with this in
To enable logging (including streaming), you need to change it to:
But Azure Web App already has an existing mechanism to enable logging, and it would be good to just honor it. It works as follows:
|
The setting.json based logging mechanism uses .NET tracing - so it's tracing from the application. Here we are talking about IIS capturing whatever was written to standard output and dumping it to a file. Very useful for troubleshooting issues (e.g. startup) but probably not as much for application logging. Application can configure logging and decide to log elsewhere in which case these entries won't show up in stdOutLog. We will hover need to verify if the setting.json based Azure logging mechanism can be used to write application logs. |
We decided to overwrite the outpath always to "?%home%\LogFiles" when publishing for Antares since the stdoutLog should be used for diagnostic purposes and the folder always exists. |
|
@davidebbo - as I said before - stdoutLogOutput is not for logging it is just for diagnosing (mostly startup) issues. It's especially useful to troubleshoot issues which happen even before we have a logger at all. Configuring a console logger and using stdoutLogOutput to log to a file is not a substitute for a file logger.
IIS does not create a folder for logging so you set |
I'm not sure I quite buy this argument. The fact is that by default apps are configured with:
Such that anything they log using Point is that if this is enabled and so is @glennc's logger, we will end up writing the same content under |
Why would applications in production log to the Console? How do you even read it when you run in Antares (let's say AspNetCoreModule does not have stdoutLog feature)? stdoutLog is a IIS/AspNetCoreModule feature and not AspNet's and you only turn it on when you need to diagnose things - it's unstructured and you may and will get additional spew not related to your application at all (e.g. when the application starts we Console.WriteLine some things, when there is a misplaced Console.WriteLine in the app it will get it). If you use stdoutLog only for diagnostic purposes you will get (especially when application starts) some additional content that logger can't get and you should not run your application with stdoutLog enabled otherwise (this is one of the reasons why it is disabled by default). |
As long as users keep that off in Azure Web Apps and primarily use the new logger, I guess we're fine. And this will probably be the guidance, with the exception of diagnosing startup condition. If some does turn it on, then they will get duplicate stream, but hopefully this will be rare. |
Agreed. |
Fixed in 31a6a12 |
Is there any update on enabling logging to azure blob? |
@Sharpeli There is no built-in logging implementation. There are implementations though with Azure sinks. Serilog has DocumentDB and Table Storage sinks. Log4Net has an Azure Blob piece. https://github.com/serilog/serilog/wiki/Provided-Sinks |
@guardrex Thanks GuardRex, looks like the log4net is incompatible with .net core. Is there any workround to make the built-in “ILoggerFactory” or "Diagnostics.Trace" can log to azure blob for asp.net core app ? |
@PureKrome says on Slack to check out NLog. He says they use it quite a lot with great success, and it has an Azure Blob Storage sink.
|
Disclaimer:
|
I believe that's what https://github.com/aspnet/AzureIntegration/ does - it wires up logging along with Serilog and pushes log data to tables/blobs/wherever. |
There isn't much in the way of guidance tho for the new package. cc/ @Rick-Anderson @danroth27 @spboyer [EDIT] I just see it in the annoucement. https://blogs.msdn.microsoft.com/webdev/2016/10/25/announcing-asp-net-core-1-1-preview-1/ |
Thanks all, I've found an simple trick for azure app ,see https://github.com/aspnet/Logging/tree/dev/src , just add the package "Microsoft.Extensions.Logging.AzureAppServices": "1.0.0-preview1-final" and update related dependencies, |
With the project created from templates the log path is set to be
.\logs\stdout
. If the user turns on logging but does not modify the path or delete the attribute the path will be used as is (publish-iis does not change path as it might have been set by the user). When publishing this project for Azure the path won't be correct and no logs are written.More details:
See: https://github.com/aspnet/Tooling-Internal/issues/540
Need to decide what we want to do.
The text was updated successfully, but these errors were encountered: