skip to Main Content

Is there a way to view logging of my Azure Function App without the use of Application Insights?

Can I write the logging of my Function app to a separate file that I can view? (edit) If so, how?

Edit: I should have mentioned that I am using Java.

2

Answers


  1. yes, I do agree with the point mentioned by @Thiago Custodio. you can use serilog in the Azure functions to view your logs.

    Here is the code provided by @Ivan Yang in this So for using Serilg in Azure functions.

      [assembly: WebJobsStartup(typeof(Startup))]
        namespace MyApp
     {
            public class Startup : IWebJobsStartup
            {
                public void Configure(IWebJobsBuilder builder)
                {
                    //other code
    
                    builder.Services.AddLogging();
                }
            }
    
    
    
        public class Functions
        {
            //other code
            private ILogger _log;
    
            public Functions(ILoggerFactory loggerFactory)
            {
                _log = loggerFactory.CreateLogger<Functions>();
            }
    
            [FunctionName("Token")]
            public async Task<IActionResult> Function1(
                [HttpTrigger()]...)
            {
                   _log.LogInformation("Function1 invoked");
            }
        }
    
    }
    
    Login or Signup to reply.
  2. Diagnostic Settings will be of help here. You can enable diagnostics to publish the logs to a storage account.

    To set the settings. Search for Diagnostic settings in the search-pane of your function app.
    enter image description here
    And then enable by providing the storage account details:
    enter image description here

    For full information refer: https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitor-log-analytics?tabs=java

    The benefit of this is: that you can continue to log using the default logging framework that the azure-functions provide. There isn’t any code change that is required.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search