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

logback encoder field becomes decoded with otel java instrumentation agent #12757

Open
howan36 opened this issue Nov 20, 2024 · 6 comments
Open

Comments

@howan36
Copy link

howan36 commented Nov 20, 2024

    <springProfile name="prod">
        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
                <layout class="com.ikea.common.spring.filter.http.CustomPatternLayout">
                    <maskPattern>(?:name|firstName|lastName|customerName)\s*(?:=|:)\s*(.+?) .</maskPattern>
                    <maskPattern>(?:address1|customerAddress)\s*(?:=|:)\s*(.+?) .</maskPattern>
                    <maskPattern>\\?"(?:address1|customerAddress)\\?"\s*:\s*\\?"(.+?)\\?"</maskPattern>
                    <maskPattern>\\?"(?:name|firstName|lastName|customerName)\\?"\s*:\s*\\?"(.+?)\\?"</maskPattern>
                    <hashPattern>\\?"(?:mobile|phone|phoneNumber|communicationPhone)\\?"\s*:\s*\\?"([+\d]+)\\?"</hashPattern>
                    <hashPattern>(?:PHONE|phone|phoneNumber|communicationPhone|mobile)\s*(?:=|:)\s*([+\d]+)</hashPattern>
                    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [trace_id=%X{trace_id} span_id=%X{span_id}] [%p][%c#%M:%L] -> %m%n</pattern>
                </layout>
            </encoder>
        </appender>

        <root level="info">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>

we use the above config to encode some sensitive field, but after received from collector, it becomes decoded

@howan36
Copy link
Author

howan36 commented Nov 20, 2024

if there are some configurations could solve that, or something missing from my side

@howan36
Copy link
Author

howan36 commented Nov 20, 2024

No description provided.

@laurit
Copy link
Contributor

laurit commented Nov 21, 2024

The layout patterns you have configured are for the console appender. Otel appender is not connected to the console appender and does not use this configuration. I believe you can use the collector to apply these patterns to the log data.

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Nov 21, 2024
@howan36
Copy link
Author

howan36 commented Nov 21, 2024

ok, thanks a lot @laurit , besides, if otel log appender could output the log format to json, i found some field s were extracted to attributes labels, and the log body seems to be text mode

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Nov 21, 2024
@howan36
Copy link
Author

howan36 commented Nov 21, 2024

for this log, the first row is the original message, and the json is the content i use transform processor to concat from attributes, if they could combine into 1 big json

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

No branches or pull requests

2 participants