1
votes

I need some help with logging for Java Apps in Azure:

1) Using Azure as PaaS, I've created an API APP configured to use Java8 + Tomcat8. And I'm trying to use log4j2 for getting application logging apart from the Tomcat logs (in a separated file). For what I know, I've permissions to write anywhere inside D:\home. So, I'll try to write to "d:\home\Logfiles\Application\". So, I created a WebApplication with some log4j2 that runs just fine in my local tomcat. But when running the same application (with the correct log file path) in Azure I don't see any logs. I even tried to fill /site/wwwroot/web.config as described in https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/ no logs this way also. How can I configure Java applicational logging in a separated file (without changing the tomcat logging (JULI logger) to log4j)?

2) Looking at the tomcat logs, I realized the Start/Stop/Restart of the WebApp doesn't mean to Start/Stop/Restart of the tomcat, so we don't have any control of it? Does someone knows what's happening behind when we do a Start/Stop/Restart in the azure portal for a webcontainer based application?

3) What's the best way to centralize Java Logging of several web applications? Using JDBCAppender or JPAAppender from log4j2?

Thanks in advance

2

2 Answers

1
votes

As I known, you have permission to write anywhere inside the path D:\home\site\, but not at the path D:\home\ that I tested. So I suggest that you can try to configure the specified path inside D:\home\site\ for application logging.

However, for logging persistence, I recommend that you can try to use Azure Table Storage for application logging. Please refer to the answered SO thread Using Azure Blob Storage with java MVC Azure Web Site to know.

For your second question, you can use the Process explorer of Kudu tool to inspect the java process via the url https://<your-app-name>.scm.azurewebsites.net/ProcessExplorer/, please see the figure below. When you stop the app, the java process will be killed. If you start the app again, you can see the java process after you firstly access the app.

enter image description here

For the third question, per my experience, I think using Azure Application Insights service is the best way. Meanwhile, Azure Application Insights support Log4j2 via the SDK. You can refer to the offical document Explore Java trace logs in Application Insights to know how to get started.

0
votes

For question 1, 2 & 3: Using the Kudu Debug Console I saw that I don't have any java process running, that's why nothing was working. Thanks for the tip!

Setting the "Always On" = "On" in "Application settings" solved my problem.

Now, even the centralized Application Insights monitoring and logs are working just fine.

Thanks a lot :)