What are app logs?
Azure provides built-in diagnostics with app logging. App logs are the output of runtime trace statements in app code. For example, you might want to check some logic in your code by adding a trace to show when a particular function is being processed. Or, you might only want to see a logged message when a particular level of error occurs. App logging is primarily for apps in preproduction and for troublesome issues, because excessive logs can carry a performance hit and quickly consume storage. For this reason, logging to the file system is automatically disabled after 12 hours.
App logging has scale limitations, primarily because files are being used to save the logged output. If you have multiple instances of an app, and the same storage is shared across all instances, messages from different instances might be interleaved, making troubleshooting difficult. If each instance has its own log file, then there are multiple logs, again making it difficult to troubleshoot instance-specific issues.
The types of logging available through the Azure App Service depends on the code framework of the app, and on whether the app is running on a Windows or Linux app host.
ASP.NET
ASP.NET apps only run on Windows app services. To log information to the app diagnostics log, use the System.Diagnostics.Trace class. There are four trace levels you can use, that correlate with the error, warning, information, and verbose logging levels shown in the Azure portal:
- Trace.TraceError(“Message”); // Writes an error message
- Trace.TraceWarning(“Message”); // Writes a warning message
- Trace.TraceInformation(“Message”); // Writes an information message
- Trace.WriteLine(“Message”); // Writes a verbose message
ASP.NET Core apps
ASP.NET Core apps can run on either Windows or Linux. To log information to Azure app logs, use the logger factory class, and then use one of six-log levels:
- logger.LogCritical(“Message”); // Writes a critical message at log level 5
- logger.LogError(“Message”); // Writes an error message at log level 4
- logger.LogWarning(“Message”); // Writes a warning message at log level 3
- logger.LogInformation(“Message”); // Writes an information message at log level 2
- logger.LogDebug(“Message”); // Writes a debug message at log level 1
- logger.LogTrace(“Message”); // Writes a detailed trace message at log level 0
For ASP.NET Core apps on Windows, these messages relate to the filters in the Azure portal in this way:
- Levels 4 and 5 are error messages.
- Level 3 is a warning message.
- Level 2 is an information message.
- Levels 0 and 1 are verbose messages.
For ASP.NET Core apps on Linux, only error messages (levels 4 and 5) are logged.
Node.js apps
For script-based Web apps, such as Node.js apps on Windows or Linux, app logging is enabled using the console() method:
- console.error(“Message”); // Writes a message to STDERR.
- console.log(“Message”); // Writes a message to STDOUT.
Both types of message are written to the Azure app service error level logs.
Logging differences between Windows and Linux hosts
To route messages to log files, Azure Web apps use the Internet Information Services (IIS) Web server. Because Windows-based Web apps are a well-established Azure service, and messaging for ASP.NET apps is tightly integrated with the underlying IIS service, Windows apps benefit from a rich logging infrastructure. For other apps, logging options are limited by the development platform, even when running on a Windows app service.
The Docker image used for the app’s container, determines the logging functionality available to Linux-based scripted apps, such as Node. Basic logging, such as using redirections to STDERR or STDOUT, uses the Docker logs. Richer logging functionality is dependent on the underlying image, and whether it’s running PHP, Perl, Ruby, and so on. To download equivalent Web application logging as provided by IIS for Windows apps, might require connecting to your container using SSH.
The following table summarizes the logging support for common app environments and hosts.
https://lernix.com.my/sap-fico-financial-accounting-training-courses-malaysia





