question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support prefix option for Logback integration

See original GitHub issue

Support prefix option <exportPrefix> for Logback integration to specify the prefix of exported MDC properties.

For example, if this xml is loaded

  <appender name="RCEA" class="com.linecorp.armeria.common.logback.RequestContextExportingAppender">
    <!-- specify the prefix of exported MDC properties -->
    <exportPrefix>armeria</exportPrefix>
    <export>req.*</export>
    <export>res.*</export>
    ...
  </appender>

then RequestContextExportingAppender exports armeria.req.path, armeria.req.service_name, armeria.res.status_code, etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
trustincommented, Oct 6, 2020

Another thing to consider is that we might add support for other logging frameworks in the future, e.g. log4j2. We might want to keep the same set of XML tags if possible for consistent user experience.

2reactions
trustincommented, Oct 3, 2020

How about <exportGroup> ?

<!-- If not wrapped with exportGroup, all directives go to the 'default export group'. -->
<prefix>...</prefix> <!-- This sets the prefix for all exports in the default export group. -->
<export>...</export>
<exports>...</exports>

<!-- exportGroup creates a new export group. -->
<exportGroup>
  <prefix>...</prefix> <!-- This sets the prefix for the exports in its group only. -->
  <export>...</export>
  <exports>...</exports>
</exportGroup>

<exportGroup>
  <export>...</export>
  <prefix>...</prefix> <!-- A user should be able to specify a prefix later -->
</exportGroup>

<exportGroup>
  <!-- No prefix tag means 'inherit from the default export group. -->
  <export>...</export>
</exportGroup>

One thing to think about is whether we need to allow an empty prefix, i.e. <prefix />. It looks somewhat confusing, so it’s probably better throwing an exception? Users can still achieve what they want with proper grouping of exports:

<exportGroup>
  <export>...</export>
</exportGroup>
<exportGroup>
  <prefix>...</prefix>
  <export>...</export>
</exportGroup>

We might also want to an additional tag that excludes some exports:

<!-- Add armeria prefix for all request properties except req.foo. -->
<export>req.foo</export>
<exportGroup>
  <prefix>armeria</prefix>
  <exports>req.*</exports>
  <exclusion>^req\.foo$</exclusion> <!-- regex -->
</exportGroup>

Makes sense?

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide To Logback - Baeldung
Logback supports the creation of custom classes for formatting messages, as well as robust configuration options for the existing ones.
Read more >
Logback-access - QOS.ch
The logback-access module, part of the standard logback distribution, integrates with Servlet containers such as Jetty or Tomcat to provide rich and ...
Read more >
How to configure logback to append special prefix for each ...
I have a class that takes string parameter in its constructor which represents it. And i want to append this string as prefix...
Read more >
Solving Your Logging Problems with Logback - Stackify
Logback is definitely a great choice when used to its full potential. ... such as slf4j support; logback-access – provides integration with ...
Read more >
83.1 Configure Logback for Logging - Spring
To configure the more fine-grained settings of a logging system, you need to use the native configuration format supported by the LoggingSystem in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found