Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine documentation on logging #8550

Merged
merged 4 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/getting-into-the-code/code-howtos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private Optional<String> genericGetFieldOrAlias(Field field, BiFunction<BibEntry
}
} else {
// Date field not in valid format
LOGGER.debug("Could not parse date " + date.get());
LOGGER.debug("Could not parse date {}", date.get());
return Optional.empty();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/tinylog-test.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
level = info
writer = console
[email protected] = debug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only meant as an example, or actually desired?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to choose a class not having extensive debug statements. I wanted to keep a line directly working. Think of novices not sure about comment characters in .properties file etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we reference it in the udpated howto:

In the .properties file, this is done for org.jabref.model.entry.BibEntry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are comments in a properties file allowed? If yes, it would be nice to give a few examples (i.e. activate debug logging for a particular class, for a module, for everything).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash character #this is a comment work