none
[Java][API Apps] Java Logging in Azure ApiApp RRS feed

  • Question

  • Hi you all, 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

    Wednesday, April 27, 2016 5:03 PM

Answers

All replies

  • Hello,

    Thank you for posting here!

    Please find the below answers for your queries.

    For the first query:

    Please make sure you set stdoutLogEnabled="true" in your web.config file.

    Please check in the code for the log4j file path to lo4j.appender.stdout.File = “\absolute path”

    Specific to your query How can I configure Java applicational logging in a separated file. Found the one of thread in SO which helps to store the output logs into separate file.

    Also, please check the logging on azure and Diagnostics and logging in Windows Azure Web Sites. For Logging persistence suggest you to use Azure Table Storage

    For the second query :

    You can use kudu console Process Explorer tab. When you start/stop the Web App the process will be killed/starts. You may check the Kudu Debug Console post for more details.

    For the third query:

    You may want to check the Application Insights service with SDK. Please check the Java trace logs in Application Insights with log4j.

    Hope this helps!

    Regards,

    Ashok

    Thursday, April 28, 2016 12:50 PM
  • Hi,

    Thanks for posting here.

    I have answered the same thread in SO for you.

    If you have any concern, please feel free to let me know. I'm pleasure to answer it at here or SO.

    Best Regards.
    Friday, April 29, 2016 2:40 AM
    Moderator
  • Thanks Ashok,

    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 again,
     Miguel



    Tuesday, May 3, 2016 9:53 AM