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

Duplicated log events in AppInsights dashboard #1345

Closed
Sherkdavid opened this issue Oct 14, 2020 · 2 comments · Fixed by #1434
Closed

Duplicated log events in AppInsights dashboard #1345

Sherkdavid opened this issue Oct 14, 2020 · 2 comments · Fixed by #1434

Comments

@Sherkdavid
Copy link

We tried using AppInsights agent 3.0.0-PREVIEW.7 to push log4j events for a JavaApplication server to see INFO level logs reported, the events are logged as expected but we are now seeing duplicated entries in the AppInsights traces.

Expected behavior

Server logs appear in the AppInsights dashboard at all levels

Actual behavior

Server logs appear but with a duplicate written for each

To Reproduce

  1. Start the java application server using Log4j2 with jvm arg -javaagent applicationinsights-agent-3.0.0-PREVIEW.7.jar
  2. Observe that events can be seen duplicated in ApplicationInsights traces

Log4j configuration

We thought this issue might have something to do with having multiple loggers receiving events with additivity="false" but it's been reproducible with a fully stripped back configuration comprising a single Logger and Appender.

<Configuration status="error" name="foo" monitorInterval="300">
  
  <Appenders>
    <RollingFile name="foo" fileName="${env:LOG_DIR:-${sys:app.home:-/tmp}/logs}/foo-server.log"
                 filePattern="$${env:LOG_DIR:-$${sys:app.home:-/tmp}/logs}/foo-server-%d{yyyy-MM-dd'T'HH:mm:ss}{UTC}.log">
      <PatternLayout pattern="%d{ISO8601}{UTC}|%-5p|%t|%c{1.}|$${ctx:CORRELATION_ID:-N/A}|%m%n" charset="UTF-8"/>
      <Policies>
        <OnStartupTriggeringPolicy minSize="1"/>
        <TimeBasedTriggeringPolicy interval="86400" modulate="true"/>
        <SizeBasedTriggeringPolicy size="200 MB"/>
      </Policies>
      <DefaultRolloverStrategy>
        <Delete basePath="${env:LOG_DIR:-${sys:app.home:-/tmp}/logs}">
          <IfFileName glob="foo-server-*.log"/>
          <IfAccumulatedFileCount exceeds="26"/>
        </Delete>
      </DefaultRolloverStrategy>
    </RollingFile>
  </Appenders>
  
  <Loggers>
    <Root level="${env:ROOT_LOG_LEVEL:-INFO}">
      <AppenderRef ref="foo"/>
    </Root>
  </Loggers>
  
</Configuration>

System information

Please provide the following information:

  • SDK Version: 3.0.0-PREVIEW.7
  • OS type and version: MacOS Mojave 10.14.6
  • Application Server type and version (if applicable): Java (Jetty 9.4.19.v20190610)
  • Using spring-boot? No
  • Additional relevant libraries (with version, if applicable): Log4j 2.12.1

Screenshots

Screenshot 2020-10-09 at 17 23 29

Unsure at what point it is events are being duplicated, ingest or egest. I'm monitoring this issue and can follow through on producing any useful debugging on the server side. We had been pushing our logging successfully using com.microsoft.azure:applicationinsights-logging-log4j2:2.6.1 prior.

@trask
Copy link
Member

trask commented Oct 21, 2020

Hi @Sherkdavid! Can post a repro that we can use to troubleshoot this?

@Sherkdavid
Copy link
Author

Hey @trask, yeah after trying to reproduce this with a minimal jar it look like duplicates are only produced when an application is run through an IDE (IntelliJ 2019-1-4 Community)..

Running with java -jar ... -javaagent:applicationinsights-agent-3.0.0-PREVIEW.7.jar seems to have the expected behavior

I've attached a zip of the gradle project if it's of any use still.
ai-dupe.zip

Screenshot 2020-10-21 at 14 51 57

@ghost ghost locked as resolved and limited conversation to collaborators Jul 20, 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

Successfully merging a pull request may close this issue.

2 participants