Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send logs to azure application insights when using logback appender for java web project #453

Closed
deepushri opened this issue Oct 25, 2017 · 4 comments
Milestone

Comments

@deepushri
Copy link

I have a java web app (springboot app) where in I want to push the logs to the application insights in azure. I am using logback as my logging framework as it is natively supported by Springboot.
I followed the following blog for the integration of the applicationInsights for my web app.

https://github.com/AzureCAT-GSI/DevCamp/tree/master/HOL/java/06-appinsights

As per this blog I have created the following:

  1. created the application insights resource in azure
  2. created the filter in my java web app to capture the http requests
  3. created ApplicationInsights.xml
  4. created logback.xml which will have the AI appender provided by Azure.

here are the snippets from my web app

  1. ApplicationInsight filter class is as follows:-

    @configuration

    public class AppInsightsConfig {

     @Bean
     public String telemetryConfig() {
         String telemetryKey = System.getenv("APPLICATION_INSIGHTS_IKEY");
         if (telemetryKey != null) {
             TelemetryConfiguration.getActive().setInstrumentationKey(telemetryKey);
         }
         return telemetryKey;
     }
    
     @Bean
     @Order(1)
     public org.springframework.boot.web.servlet.FilterRegistrationBean aiFilterRegistration() {
         FilterRegistrationBean registration = new FilterRegistrationBean();
         registration.setFilter(new WebRequestTrackingFilter());
         registration.addUrlPatterns("/**");
         registration.setOrder(1);
         return registration;
     } 
    
     @Bean(name = "WebRequestTrackingFilter")
     public Filter WebRequestTrackingFilter() {
         return new WebRequestTrackingFilter();
     }	
    

    }


  1. ApplicationInsights.xml (src/main/resources folder)

     <!-- The key from the portal: -->
     
     <InstrumentationKey>my app key</InstrumentationKey>
     
     
     <!-- HTTP request component (not required for bare API) -->
     
     <TelemetryModules>
         <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
     </TelemetryModules>
     
     <!-- Events correlation (not required for bare API) -->
     <!-- These initializers add context data to each event -->
     
     <TelemetryInitializers>
         <Add   type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
         <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
     
     </TelemetryInitializers>
     </ApplicationInsights>  
    

  1. Logback.xml is as follows:-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="aiAppender" 
        class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
    </appender>
    <root level="trace">
        <appender-ref ref="aiAppender" />
    </root>

    <logger name="org.springframework.web" level="INFO"/>
</configuration>

The issue is that I am not able to push the logs to the app insights. However I am able to get the telemetries in the app insights.

Note: I am using the latest versions of appinsights libraries (core and web)

@deepushri deepushri changed the title Unable to send logs to azure application insights when using logbook appender for java web project Unable to send logs to azure application insights when using logback appender for java web project Oct 25, 2017
@dhaval24
Copy link
Contributor

@deepushri thanks for letting us know. We are aware of the logback issue and will try to repro and address it in upcoming releases.

@dhaval24 dhaval24 added this to the future milestone Oct 27, 2017
@grlima grlima added Bug and removed Bug labels Oct 30, 2017
@dhaval24
Copy link
Contributor

@deepushri have you tried if this issue persist with the latest released version of sdk v2.0.0-BETA. I believe that it should have been resolved. Let me know so we can close this issue

@dhaval24
Copy link
Contributor

@deepushri is there any update on this issue from your end. We believe we have fixed this issue in our latest beta sdk and is good to close. I am waiting to hear from you if there is still something wrong. Let me know.

@dhaval24
Copy link
Contributor

dhaval24 commented Mar 3, 2018

@deepushri @kmalhotra2504 we believe this issue has been fixed in all our subsequent releases after 1.0.10. You may try out the latest stable SDK 2.0.1. I am closing this as of now and you can always reopen if the issue persists.

@dhaval24 dhaval24 closed this as completed Mar 3, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants