logback / LOGBACK-1645 [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/LOGBACK-1645

==============================
 Issue created
------------------------------

Martin created this issue on 27/Jun/22 4:01 PM
Summary:              Disable pattern programatically in current thread.
Issue Type:           Improvement
Assignee:             Logback dev list
Components:           logback-core
Created:              27/Jun/22 4:01 PM
Labels:               logging
Priority:             Minor
Reporter:             Martin
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. 
  
  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}
  
  Related to:  https://jira.qos.ch/browse/SLF4J-552. 


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)

_______________________________________________
logback-dev mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to