[slf4j-dev] [JIRA] Updates for SLF4J-552: Disable pattern programatically in current thread.
QOS.CH (JIRA)
noreply-jira at qos.ch
Mon Jun 13 14:37:00 CEST 2022
SLF4J / SLF4J-552 [Open]
Disable pattern programatically in current thread.
==============================
Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.
View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-552
==============================
Issue created
------------------------------
Martin created this issue on 13/Jun/22 2:24 PM
Summary: Disable pattern programatically in current thread.
Issue Type: New Feature
Assignee: SLF4J developers list
Components: slf4j-simple
Created: 13/Jun/22 2:24 PM
Priority: Minor
Reporter: Martin
Severity: enhancement
Description:
Working with logger is essential for troubleshooting but sometime there is way too much debug logs. Sometime they are too verbose but still needed.
I came across a issue with disk spaces and the logs were top blame.
I want to propose a simple feature to the logger. Sadly I do not know who is in the top of the pyramide. Slf4j seem to be the place to begin with.
Let say I have a really fast and verbose thread algorithm.
{code:java}
2022-06-10 14:27:23:123 -0400 [normal] DEBUG org.slf4j.impl.App - Calling internal process
2022-06-10 14:27:23:123 -0400 [normal] DEBUG org.slf4j.impl.App - Clean up list from empty or null string
2022-06-10 14:27:23:123 -0400 [normal] DEBUG org.slf4j.impl.App - Removing : ""
2022-06-10 14:27:23:123 -0400 [normal] DEBUG org.slf4j.impl.App - Removing : "null"
<...>
2022-06-10 14:27:23:123 -0400 [normal] INFO org.slf4j.impl.App - Listing entries
2022-06-10 14:27:23:124 -0400 [compact] DEBUG org.slf4j.impl.App - Return to Normal log
{code}
I propose to include a flag that will keep the logging and avoid duplicated the pattern.
I want to:
Use ThreadLocal to avoid impacting all the other logs.
Enable programmatically to be specific for known verbose path only
Keep the initial pattern of the first log call.
Enable it only for debug level, other level will continue to be log with the pattern.
Closable to be easy to use.
Result must be something like this:
{code:java}
2022-06-10 14:27:23:119 -0400 [compact] INFO org.slf4j.impl.App - Enabling compact logging
2022-06-10 14:27:23:120 -0400 [compact] INFO org.slf4j.impl.App - Listing entries
2022-06-10 14:27:23:120 -0400 [compact] DEBUG org.slf4j.impl.App - Calling internal process
Clean up list from empty or null string
Removing : ""
Removing : "null"
<...>
2022-06-10 14:27:23:120 -0400 [compact] DEBUG org.slf4j.impl.App - Return to Normal log
{code}
The code will be use like this:
{code:java}
@Slf4j
public class App {
public void publicCall( List<String> list ) {
log.info("Enabling compact logging");
try (AutoCloseable ignored = ((CompactLogger)log).beginCompactLogging()) {
processList(list);
} catch (Exception e) {
log.error("Process issue", e);
}
log.debug("Return to Normal log");
}
}
{code}
==============================
This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)
More information about the slf4j-dev
mailing list