-
Notifications
You must be signed in to change notification settings - Fork 18
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
Using MDC for labels #71
Comments
Hello, yes, you can do that. In log4j you have variable <appenders>
<Loki name="Loki">
...
<Label name="tid1" pattern="%X{tid}"/>
<Label name="tid2" value="${ctx:tid}"/>
<Label name="tid3" pattern="%mdc{tid}"/>
</Loki>
</appenders> The <Label name="default_value_test" value="${ctx:missing:-use_this_if_missing}"/> You might find out this documentation helpful:
|
@stefnats Please let me know or reopen the issue if you need more info. |
Is there any way to do the same but without knowing previously the name of the MDC vars? I have dynamic context variables depending on the code and i don't want to re-write my xml every time i add a new one. By instance, i have 2 methods with 3 different value, can i do something at XML to show 3 without telling the name up front? // Method 1.. // Method 2 |
@lucianocallero I don't think it is possible. Is it possible in other appenders? I guess we could add a switch that will convert the whole thread context into loki labels. |
Thanks. That would be great. In me case more than one appender does not fit because labels are dynamic depending on the context of the appliances. |
Hey there,
i want to migrate from ELK Stack to Loki.
Is it possible to send the MDC Parameters (set dynamically in
ThreadContext.put(key, value)
) as Labels to Loki? And how would i achieve this with log4j2?Thanks in advance
The text was updated successfully, but these errors were encountered: