<commit_before>## SLF4J Logging ##

> The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging,
> logback, log4j) allowing the end user to plug in the desired logging
> framework at deployment time.

---

How to Declare
--------------

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    1.private static final Logger LOGGER = LoggerFactory.getLogger(Test.class)
    2.private final Logger logger = LoggerFactory.getLogger(getClass())


**Logger should be final & private 
static or non static ?**

 1. PMD recommends static  (“LoggerIsNotStaticFinal” rule)
 2. SIF4 recommends non static http://www.slf4j.org/faq.html#declared_static
 3. 
Naming convention of variable LOGGER/logger is a matter of preference - PMD and SONAR recommends LOGGER(uppercase)

---

How to Log
----------

1. There shouldn't be any concatenation. 
2. Use SLF4J expressions , It will delay the construction of the string.
3. Do:
    	LOGGER.debug(“Some Object={}”,obj);
**If debug is disabled  - the message will never be constructed
Just that you are passing two variables to the debug method.**
	1. Some Object={}
	2. obj
3. Implementation of debug method constructs the message only if the debug is enabled.

---

How to Log (continued)
----------------------
DON'T DO THIS


    	LOGGER.debug(“Some Object=" + obj)

**Even If debug is disabled  - the message will be constructed.**
1. Here debug method is called with one argument.

(ie) - 'Some Object='+`obj.toString()` is evaluated and concatenated to a single args.
The message is constructed even before calling the method.

---

What to Log
-----------
**In case of exceptions , brief the issue always log the stack trace**
1. Say if IOException occurred while reading a file
2. Do:
    	LOGGER.error(“Error occurred - 
    	Unable to read the file {}”,absoluteFilePath,ex)
Last argument to the error method should be throwable.

3. Dont:
    	LOGGER.error(“Error occurred”,ex)
    	LOGGER.error(“Error occurred {}”,ex.getMessage())<commit_msg>cosmetic changes<commit_after>## SLF4J Logging ##

> The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging,
> logback, log4j) allowing the end user to plug in the desired logging
> framework at deployment time.

---

How to Declare
--------------

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    1.private static final Logger LOGGER = LoggerFactory.getLogger(Test.class)
    2.private final Logger logger = LoggerFactory.getLogger(getClass())


**Logger should be final & private 
static or non static ?**

 1. PMD recommends static  (“LoggerIsNotStaticFinal” rule)
 2. SIF4 recommends non static http://www.slf4j.org/faq.html#declared_static
 3. 
Naming convention of variable LOGGER/logger is a matter of preference - PMD and SONAR recommends LOGGER(uppercase)

---

How to Log
----------

1. There shouldn't be any concatenation. 
2. Use SLF4J expressions , It will delay the construction of the string.
3. Do:
    	LOGGER.debug(“Some Object={}”,obj);
**If debug is disabled  - the message will never be constructed
Just that you are passing two variables to the debug method.**
	1. Some Object={}
	2. obj
3. Implementation of debug method constructs the message only if the debug is enabled.

---

How to Log (continued)
----------------------
DON'T DO THIS


    	LOGGER.debug(“Some Object=" + obj)

**Even If debug is disabled  - the message will be constructed.**
1. Here debug method is called with one argument.

(ie) - 'Some Object='+`obj.toString()` is evaluated and concatenated to a single args.
The message is constructed even before calling the method.

---

What to Log
-----------
**In case of exceptions , brief the issue always log the stack trace**

1. Say if IOException occurred while reading a file
2. Do:
    	LOGGER.error(“Error occurred - 
    	Unable to read the file {}”,absoluteFilePath,ex)
Last argument to the error method should be throwable.

3. Dont:
    	LOGGER.error(“Error occurred”,ex)
    	LOGGER.error(“Error occurred {}”,ex.getMessage())
{'fraction_non_alphanumeric': 0.1126018207954001, 'fraction_numerical': 0.011020603737422138, 'mean_word_length': 3.2732855680655066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4586211', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1210, 'n_words': 516}