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

logging - apply layout for log4j event #1241

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skaabaoui
Copy link

@skaabaoui skaabaoui commented May 15, 2020

Fix Custom layout pattern like "%d --- %m%n" can not be used with appinsights log4j v2.

The PatternLayout has no effect on the log4j sent to Azure AppInsights:

e.g:
<Configuration packages="com.microsoft.applicationinsights.log4j.v2">
    <Appenders>
        <ApplicationInsightsAppender name="aiAppender" instrumentationKey="my_instrumentation_key">
               <PatternLayout pattern="%d --- %m%n" />
        </ApplicationInsightsAppender>
    </Appenders>

    <Loggers>
        <AsyncRoot level="INFO">
            <AppenderRef ref="aiAppender" />
        </AsyncRoot>

        <!-- AsyncLogger -->
        ...  

    </Loggers>
</Configuration>

@msftclas
Copy link

msftclas commented May 15, 2020

CLA assistant check
All CLA requirements met.

@skaabaoui
Copy link
Author

Hello @littleaj, can you please review this PR ?

@trask
Copy link
Member

trask commented May 29, 2020

Hi @skaabaoui, the MDC properties should already be getting captured under customDimensions

@skaabaoui
Copy link
Author

Hi @skaabaoui, the MDC properties should already be getting captured under customDimensions

Hi @trask, thank you for your feedback.
the issue here that for any custom pattern that you define using PatternLayout in the log4j2.xml file, has no effect in the format of the trace displayed on appinsights.

We have always the default trace format of appinsights logs. Using this fix, we can change the trace format of the logs sent to appinsights according to our custom PatternLayout.

@skaabaoui
Copy link
Author

skaabaoui commented Jun 3, 2020

Hi @trask, Can you please review this PR or ask someone to review it ?

@skaabaoui
Copy link
Author

Dear Members,

Can someone please review this PR ?
Thank you.

Best Regards,

@skaabaoui
Copy link
Author

Dear Members,

Can you please review this PR ?

Kind Regards,
Salah.

@vburmus
Copy link

vburmus commented May 10, 2024

Any updates on this? I have the same issue: custom logback layout is not used in App Insights

@vburmus
Copy link

vburmus commented May 10, 2024

@skaabaoui How did you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants