diff --git a/CHANGELOG.md b/CHANGELOG.md index d0386a4f943..71be86913a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,11 +23,13 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed - 'Get full text' now also checks the file url. [#568](https://github.com/koppor/jabref/issues/568) -- JabRef writes a new backup file only if there is a change. Before, JabRef created a backup upon start. [#9679](https://github.com/JabRef/jabref/pull/9679) +- We modified the `Add Group` dialog to use the most recently selected group hierarchical context. [#9141](https://github.com/JabRef/jabref/issues/9141) - We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) -- We streamlined the paths for logs and backups: The parent path fragement is always `logs` or `backups`. +- JabRef writes a new backup file only if there is a change. Before, JabRef created a backup upon start. [#9679](https://github.com/JabRef/jabref/pull/9679) - Backups of libraries are not stored per JabRef version, but collected together. -- We modified the `Add Group` dialog to use the most recently selected group hierarchical context [#9141](https://github.com/JabRef/jabref/issues/9141) +- We streamlined the paths for logs and backups: The parent path fragement is always `logs` or `backups`. +- `log.txt` now contains debug messages. Debugging needs to be enabled explicitly. [#9678](https://github.com/JabRef/jabref/pull/9678) +- `log.txt` does not contain entries for non-found files during PDF indexing. [#9678](https://github.com/JabRef/jabref/pull/9678) - We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536) diff --git a/docs/code-howtos/logging.md b/docs/code-howtos/logging.md index 741600cd625..09b252b525e 100644 --- a/docs/code-howtos/logging.md +++ b/docs/code-howtos/logging.md @@ -5,20 +5,44 @@ parent: Code Howtos 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: +Obtaining a logger for a class: - ```java - private static final Logger LOGGER = LoggerFactory.getLogger(.class); - ``` +```java +private static final Logger LOGGER = LoggerFactory.getLogger(.class); +``` -* If the logging event is caused by an exception, please add the exception to the log message as: +Please always use `LOGGER.debug` for debugging. - ```java - catch (SomeException e) { - LOGGER.warn("Warning text.", e); - ... - } - ``` +Example: + +```java +String example = "example"; +LOGGER.debug("Some state {}", example); +``` + +Enable logging in `tinylog.properties`: + +```properties +level@org.jabref.example.ExampleClass = debug +``` + +If the logging event is caused by an exception, please add the exception to the log message as: + +```java + catch (SomeException e) { + LOGGER.warn("Warning text.", e); + ... + } +``` + +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`. +In the `.properties` file, this is done for `org.jabref.model.entry.BibEntry`. + +## Further reading + +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 (`{}`). +Head to for examples. -* 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`. 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`. diff --git a/src/main/java/org/jabref/cli/Launcher.java b/src/main/java/org/jabref/cli/Launcher.java index a0a9f7450f8..bc9dd85d26e 100644 --- a/src/main/java/org/jabref/cli/Launcher.java +++ b/src/main/java/org/jabref/cli/Launcher.java @@ -108,7 +108,7 @@ private static void addLogToDisk() { // https://tinylog.org/v2/configuration/#shared-file-writer Map configuration = Map.of( "writerFile", "shared file", - "writerFile.level", "info", + "writerFile.level", "debug", "writerFile.file", directory.resolve("log.txt").toString(), "writerFile.charset", "UTF-8"); diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java index 975cf83b1ec..4fea4b638a5 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/PdfIndexer.java @@ -188,7 +188,7 @@ private void writeToIndex(BibEntry entry, LinkedFile linkedFile) { } Optional resolvedPath = linkedFile.findIn(databaseContext, filePreferences); if (resolvedPath.isEmpty()) { - LOGGER.warn("Could not find {}", linkedFile.getLink()); + LOGGER.debug("Could not find {}", linkedFile.getLink()); return; } try { diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index 436f2b070c7..da736d6e974 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -248,13 +248,17 @@ public static Path getFulltextIndexBasePath() { public Path getFulltextIndexPath() { Path appData = getFulltextIndexBasePath(); + Path indexPath; if (getDatabasePath().isPresent()) { - LOGGER.info("Index path for {} is {}", getDatabasePath().get(), appData); - return appData.resolve(String.valueOf(this.getDatabasePath().get().hashCode())); + indexPath = appData.resolve(String.valueOf(this.getDatabasePath().get().hashCode())); + LOGGER.debug("Index path for {} is {}", getDatabasePath().get(), indexPath); + return indexPath; } - return appData.resolve("unsaved"); + indexPath = appData.resolve("unsaved"); + LOGGER.debug("Using index for unsaved database: {}", indexPath); + return indexPath; } @Override diff --git a/src/main/resources/tinylog.properties b/src/main/resources/tinylog.properties index 26696d06933..b4340fa32e9 100644 --- a/src/main/resources/tinylog.properties +++ b/src/main/resources/tinylog.properties @@ -5,3 +5,5 @@ writerAzure = application insights # More shrunk exception logs. See https://tinylog.org/v2/configuration/#strip-stack-trace-elements for details exception = strip: jdk.internal + +#level@org.jabref.model.entry.BibEntry = debug