From 454a4d6fd215c4b0c88171f85e6508b32364603a Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 8 Mar 2022 20:24:18 +0100 Subject: [PATCH 1/4] Refine documentation on logging --- docs/getting-into-the-code/code-howtos.md | 8 +++++++- src/main/java/org/jabref/model/entry/BibEntry.java | 2 +- src/test/resources/tinylog-test.properties | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index 42f96fc958f..ead1c209d6e 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -119,7 +119,8 @@ If you want to catch the event you'll have to register your listener class with ## Logging -JabRef uses the logging facade [SLF4j](https://www.slf4j.org/). All log messages are passed internally to [log4j2](https://logging.apache.org/log4j/2.x/) which handles any filtering, formatting and writing of log messages. +JabRef uses the logging facade [SLF4j](https://www.slf4j.org/). +All log messages are passed internally to [tinylog](https://tinylog.org/v2/) which handles any filtering, formatting and writing of log messages. * Obtaining a logger for a class: @@ -137,6 +138,11 @@ JabRef uses the logging facade [SLF4j](https://www.slf4j.org/). All log messages ``` * SLF4J also support parameterized logging, e.g. if you want to print out multiple arguments in a log statement use a pair of curly braces. [Examples](https://www.slf4j.org/faq.html#logging_performance) +* When running tests, `tinylog-debug.properties` is used. + As default, only `info` is logged. + When developing, it makes sense to use `debug` as log level. + One can change the log level per class using the pattern `level@class=debug` is set to `debug`. + In the `.properties` file, this is done for `org.jabref.model.entry.BibEntry`. ## Using Localization correctly diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 546afc1916c..5be8671718a 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -469,7 +469,7 @@ private Optional genericGetFieldOrAlias(Field field, BiFunction Date: Wed, 9 Mar 2022 20:51:13 +0100 Subject: [PATCH 2/4] Update docs/getting-into-the-code/code-howtos.md --- docs/getting-into-the-code/code-howtos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index ead1c209d6e..d51dc5e7510 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -138,7 +138,7 @@ All log messages are passed internally to [tinylog](https://tinylog.org/v2/) whi ``` * SLF4J also support parameterized logging, e.g. if you want to print out multiple arguments in a log statement use a pair of curly braces. [Examples](https://www.slf4j.org/faq.html#logging_performance) -* When running tests, `tinylog-debug.properties` is used. +* When running tests, `tinylog-test.properties` is used. It is located under `src/test/resources` As default, only `info` is logged. When developing, it makes sense to use `debug` as log level. One can change the log level per class using the pattern `level@class=debug` is set to `debug`. From 5915111ff032f015b7fd81ebd35adddf509638b5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 10 Mar 2022 00:26:11 +0100 Subject: [PATCH 3/4] Update code-howtos.md --- docs/getting-into-the-code/code-howtos.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index d51dc5e7510..6759b6a38d8 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -18,7 +18,7 @@ Please read [https://github.com/cxxr/better-java](https://github.com/cxxr/better Principles: -* All Exceptions we throw should be or extend `JabRefException`; This is especially important if the message stored in the Exception should be shown to the user. `JabRefException` has already implemented the `getLocalizedMessage()` method which should be used for such cases \(see details below!\). +* All exceptions we throw should be or extend `JabRefException`; This is especially important if the message stored in the Exception should be shown to the user. `JabRefException` has already implemented the `getLocalizedMessage()` method which should be used for such cases \(see details below!\). * Catch and wrap all API exceptions \(such as `IOExceptions`\) and rethrow them * Example: @@ -138,7 +138,7 @@ All log messages are passed internally to [tinylog](https://tinylog.org/v2/) whi ``` * SLF4J also support parameterized logging, e.g. if you want to print out multiple arguments in a log statement use a pair of curly braces. [Examples](https://www.slf4j.org/faq.html#logging_performance) -* When running tests, `tinylog-test.properties` is used. It is located under `src/test/resources` +* When running tests, `tinylog-test.properties` is used. It is located under `src/test/resources`. As default, only `info` is logged. When developing, it makes sense to use `debug` as log level. One can change the log level per class using the pattern `level@class=debug` is set to `debug`. From 7dcf994a957ff6afb41a6db434b38e0e5c15aa07 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 11 Mar 2022 19:49:32 +0100 Subject: [PATCH 4/4] Update tinylog-test.properties --- src/test/resources/tinylog-test.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/resources/tinylog-test.properties b/src/test/resources/tinylog-test.properties index e5ca0a9d82d..34b759ac485 100644 --- a/src/test/resources/tinylog-test.properties +++ b/src/test/resources/tinylog-test.properties @@ -1,3 +1,4 @@ level = info writer = console -level@org.jabref.model.entry.BibEntry = debug +# uncomment the following line to enable debug logging outputs +#level@org.jabref.model.entry.BibEntry = debug