spring-cloud-function icon indicating copy to clipboard operation
spring-cloud-function copied to clipboard

Function startup logs

Open ffarinha-msft opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe.

On Azure Function App, the first time a function runs there will be some startup logs coming from "org.springframework.cloud.function.utils.FunctionClassUtils" to the STDOUT which will be captured by the Application Insights Agent running on the same (when setting APPLICATIONINSIGHTS_ENABLE_AGENT is turned on)

Example: image

Describe the solution you'd like I would like to have a flag that allowed me to turn of information level logs from org.springframework.cloud.function.utils.FunctionClassUtils. If there is such a flag I haven't been able to find it.

Describe alternatives you've considered I was able to turn of information level logs from org.springframework.boot, by adding the following properties to my application.properties file:

spring.main.banner-mode=off logging.level.org.springframework=WARN spring.main.log-startup-info=OFF

Example of the log I turned off image

But I tried adding all the below properties to my application.properties file without any luck:

logging.level.org.springframework.cloud.config=WARN logging.level.org.springframework.cloud.function=WARN logging.level.org.springframework.cloud=WARN logging.level.org.springframework.cloud.function.utils.FunctionClassUtils=WARN logging.level.org.springframework.cloud.function.utils=WARN logging.level.root=OFF

I also tried to use the preview feature of Application Insights to filter the logs but I found that it will also turn off my custom logging https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-sampling-overrides#how-it-works

ffarinha-msft avatar Sep 13 '23 14:09 ffarinha-msft

Hi @ffarinha-msft, could you please provide a detailed instructions how to configure and see the above traces/logs in the azure/portal?

tzolov avatar Sep 25 '23 17:09 tzolov

Hi @tzolov

Thank you for coming back to me.

The issue described can be reproduce with a simple hello world spring function has this examples:

https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/getting-started-with-spring-cloud-function-in-azure

https://github.com/Azure-Samples/hello-spring-function-azure

Once you have your simple hello world spring function application you deploy the code to a Linux Azure Function App (I did not test on Windows).

Then you trigger the function execution and you will notice that the first invocation will have the initialization logs I mentioned: image

image

image

If you want to view more details about the logs namely the logger where they are coming from (as I showed on the original post) you can access directly the Application Insights on the Azure Portal, got to "Transaction Search" and search for "Searching for start class" you will find records like this: image

You then double click on one of those results and a blade like below will open where you can then see more details about each of the logs:

image

Important:

As mentioned before to so those logs you need to have the App Insights Agent turned on which can be done by navigating to the function app and then to App Insights blade and activate the "Recommended" log option image

ffarinha-msft avatar Sep 28 '23 08:09 ffarinha-msft

@ffarinha-msft ,

Thank you for your update, but unfortunately I'm still not able to reach the portal pages you've shared above. As you can see below i have the APPLICATIONINSIGHTS_ENABLE_AGENT set to true the App Insights seems enabled but i can not see the Developer/Monitor menu options. I'm not Azure portal savvy. Do i need a special plan?

Screenshot 2023-10-30 at 15 06 05_anonymized Screenshot 2023-10-30 at 15 03 05_anonymized Screenshot 2023-10-30 at 15 04 26_anonymized

tzolov avatar Oct 30 '23 14:10 tzolov

Hi @tzolov

Thank you for coming back.

It looks like you were almost there (you don't need any special plan) :)

You already accessed Application Insights resource from the screen shot you shared. Once there you need to click on "Tansaction Search":

image

Then you search for the log message we are after. Note the log only happens after on the first function execution so you might need to restart the function app and then trigger the function again. Also important to note that the logs on App Insights my take a couple of minutes to show up.

image

You then double click on one of those results and a blade like below will open where you can then see more details about each of the logs: image

ffarinha-msft avatar Oct 30 '23 18:10 ffarinha-msft