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

GH-1970: fix logger name in SPARQLProtocolSession #1971

Conversation

aschwarte10
Copy link
Contributor

The SparqlProtocolSession uses this.getClass() as a name for the logger.

When having an extension of the class, this leads to misleading log
output. Particularly the logging levels are also harder to control
(w.r.t namespacing and packaging).

The general recommendation for logger names should be to use the class
name, at least it should adhere to the rdf4j package structure.

GitHub issue resolved: #1970

The SparqlProtocolSession uses this.getClass() as a name for the logger.

When having an extension of the class, this leads to misleading log
output. Particularly the logging levels are also harder to control
(w.r.t namespacing and packaging).

The general recommendation for logger names should be to use the class
name, at least it should adhere to the rdf4j package structure.
@@ -148,7 +148,7 @@
*/
private final int maximumUrlLength;

final Logger logger = LoggerFactory.getLogger(this.getClass());
final Logger logger = LoggerFactory.getLogger(SPARQLProtocolSession.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw. I prefer final static and possibly private for loggers.

Copy link
Contributor

@abrokenjester abrokenjester Mar 6, 2020

Choose a reason for hiding this comment

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

I agree with preferring private: as this example shows, inheriting loggers is just a recipe for confusion. Unfortunately, this was designed for this purpose in the past, so we're stuck with it at least until the next major release.

I'm not sure why you prefer static though. We use a LoggerFactory so there is very little overhead. And there may be issues caused by static logger references in some applications (see https://cwiki.apache.org/confluence/display/COMMONS/Logging+StaticLog ).

Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't aware of that issue. I mostly like static loggers because you can reference them from static context too.

Copy link
Contributor

@abrokenjester abrokenjester left a comment

Choose a reason for hiding this comment

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

Good as a bugfix. We can follow up on a more consistent approach throughout the code base in a separate issue.

@abrokenjester abrokenjester merged commit 43ef209 into eclipse-rdf4j:master Mar 6, 2020
@aschwarte10 aschwarte10 deleted the issues/#1970-fix-SparqlSession-logger branch October 31, 2020 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SparqlProtocolSession uses this.getClass() as logger name
3 participants