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

No log output on Azure Web Site #773

Closed
simontaylor81 opened this Issue Jul 26, 2015 · 5 comments

Comments

Projects
None yet
6 participants
@simontaylor81

simontaylor81 commented Jul 26, 2015

I'm testing out deploying an asp.net 5 app on Azure websites, but I'm having trouble getting any log output from the application. The azure docs say you just need to write to System.Diagnostics.Trace, but that doesn't seem to work. I tried Console.WriteLine as well for good measure, but no dice.

Steps to reproduce:

  1. Clone this repo: https://github.com/simontaylor81/AspNet5TraceTest (this is a very simple app that just writes to System.Diagnostics.Trace on every request).
  2. Deploy to Azure websites (e.g. using Visual Studio's publish option).
  3. Enable verbose application logging for the site in the Azure portal.
  4. View the application log somehow (e.g. in VS, command line, portal or kudu).
  5. Browse to the site to make a request (which should trigger the Trace call).
  6. Nothing appears in the log.

Is this something that should be working? I may be missing something in the Azure config, but I've tried pretty much everything without much success.

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher
Member

Tratcher commented Jul 28, 2015

@mgolois

This comment has been minimized.

Show comment
Hide comment
@mgolois

mgolois Nov 20, 2015

Has this issue been resolved? or any work around?

mgolois commented Nov 20, 2015

Has this issue been resolved? or any work around?

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Nov 20, 2015

Member

Trace.WriteLine won't work in azure because ASP.NET sites don't read web.config (no config hierarchy),

Member

davidfowl commented Nov 20, 2015

Trace.WriteLine won't work in azure because ASP.NET sites don't read web.config (no config hierarchy),

@DavidKarlas

This comment has been minimized.

Show comment
Hide comment
@DavidKarlas

DavidKarlas Nov 21, 2015

@mgolois Workaround I'm using atm... Install Serilog.Framework.Logging NuGet package...

Add this code:

if (System.IO.Directory.Exists("D:\\home\\LogFiles\\application\\"))
{
    loggerFactory.AddSerilog(new LoggerConfiguration().WriteTo.File("D:\\home\\LogFiles\\application\\YourAppName.txt", fileSizeLimitBytes: 20 * 1024 * 1024).CreateLogger());
}

Inside public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) method.

Then you can connect with FTP client and download file... Unfortunately it's saying file used by another process(I should probably find way for Serilog to share read access...). But for now I prefer to just open Azure console and do "cp YourAppName.txt LogFileCopy.txt" and download LogFileCopy.txt...

I also noticed that Log Streaming was working... But it's not working anymore at this point(maybe since I tried to access via FTP) :(

DavidKarlas commented Nov 21, 2015

@mgolois Workaround I'm using atm... Install Serilog.Framework.Logging NuGet package...

Add this code:

if (System.IO.Directory.Exists("D:\\home\\LogFiles\\application\\"))
{
    loggerFactory.AddSerilog(new LoggerConfiguration().WriteTo.File("D:\\home\\LogFiles\\application\\YourAppName.txt", fileSizeLimitBytes: 20 * 1024 * 1024).CreateLogger());
}

Inside public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) method.

Then you can connect with FTP client and download file... Unfortunately it's saying file used by another process(I should probably find way for Serilog to share read access...). But for now I prefer to just open Azure console and do "cp YourAppName.txt LogFileCopy.txt" and download LogFileCopy.txt...

I also noticed that Log Streaming was working... But it's not working anymore at this point(maybe since I tried to access via FTP) :(

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Dec 31, 2017

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

aspnet-hello commented Dec 31, 2017

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

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