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

Move some info logged by the WebApp CL as INFO to DEBUG/FINE level to reduce noise #24944

Conversation

OndroMih
Copy link
Contributor

@OndroMih OndroMih commented May 5, 2024

With this, the following is logged in INFO during app deployment:

[#|2024-05-05T05:23:24.750875+02:00|INFO|GF 7.0.15-SNAPSHOT|org.glassfish.web.loader.WebappClassLoader|_ThreadID=300;_ThreadName=RunLevelControllerThread-1714879404711;_LevelValue=800;|
  close(), WebappClassLoader classloader for application: myapp|#]

The following is not logged as INFO anymore, rather as DEBUG/FINE. As INFO is the default log level, it's a noise in logs which is mostly for troubleshooting and it's better to have it in DEBUG level, only if requested:

[2024-05-05T05:10:08.836483+02:00] [GF 7.0.15-SNAPSHOT] [FINE] [] [org.glassfish.web.loader.WebappClassLoader] [tid: _ThreadID=64 _ThreadName=admin-listener(4)] [levelValue: 500] [[
  close(), this:
org.glassfish.web.loader.WebappClassLoader@44694e1c[name=unknown], urls=[
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/classes/
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/byte-buddy-1.12.18.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jakarta.activation-api-2.1.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/lombok-1.18.28.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/antlr4-runtime-4.10.1.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jboss-logging-3.5.0.Final.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jaxb-runtime-4.0.2.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jakarta.transaction-api-2.0.1.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/commons-logging-1.2.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/txw2-4.0.2.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/classmate-1.5.1.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/hibernate-core-6.2.6.Final.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jaxb-core-4.0.2.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/commons-dbcp2-2.9.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/h2-2.1.214.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jakarta.inject-api-2.0.1.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jakarta.xml.bind-api-4.0.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/angus-activation-2.0.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/hibernate-commons-annotations-6.0.6.Final.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jakarta.persistence-api-3.1.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/istack-commons-runtime-4.1.1.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/commons-pool2-2.10.0.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/applications/myapp/WEB-INF/lib/jandex-3.0.5.jar
file:/glassfish/appserver/distributions/glassfish/target/stage/glassfish7/glassfish/domains/domain1/generated/ejb/myapp/
][webAppName=myapp, delegate=true, context=unknown, status=RUNNING, antiJARLocking=false, securityManager=false, packageDefinitionSecurityEnabled=false, repositories=RepositoryManager[WEB-INF/classes/], notFound.size=2, pathTimestamps.size=24, resourceEntryCache.size=5]]]

Jersey 3.1.6 depends on it but GF had an older version. Admin Console failed to load.
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
@@ -267,7 +269,12 @@ public final class WebappClassLoader extends GlassfishUrlClassLoader
* but no defined repositories.
*/
public WebappClassLoader(ClassLoader parent) {
this(parent, "unknown");
Copy link
Contributor

Choose a reason for hiding this comment

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

I am against this change, it is confusing and doesn't bring a value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean it doesn't bring any value that the log message says which application is related to the web app classloader? I thought it's very important, otherwise the new INFO message just says that some web app classloader was closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, I can just change the log level of the original message rom INFO to DEBUG. I don't think it's important to log an INFO message when classloader is closed, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean that it logs the value just in one case of five possible creations of the classloader. If it should know the name of the application, it should know it always, without any "unknown" value.

@@ -1131,7 +1138,9 @@ public void close() throws IOException {
if (status == LifeCycleStatus.CLOSED) {
return;
}
LOG.log(INFO, "close(), this:\n{0}", this);
LOG.log(INFO, () -> "close(), " + this.getClass().getSimpleName()
Copy link
Contributor

Choose a reason for hiding this comment

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

The original state was very useful for quite regular issues of users who used incompatible dependencies packed directly to war. And it doesn't log too often, just on CL close.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It logs one every app deployment. To me, the big INFO message with urls is just noise. INFO messages to me are short statements about what's going on, with a few simple values. Not something that takes the whole screen to show the whole message. That's either CONFIG (which isn't supported by System.Logger), or DEBUG, because it's only relevant in case of issues. In the end, the urls list only shows what's inside WEB-INF/lib in the WAR, people can unpack the WAR and see.

Copy link
Contributor

Choose a reason for hiding this comment

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

Knowing simple name of the closed classloader class is worthless. Currently it reports some statistics and also the list of managed libraries, which is very useful in many use cases (missing/duplicit/harmful dependencies, etc). I use it nearly everyday, with some issues detected which were not resolved yet.
We can discuss that with others - if I am the only one who uses it or not.

Btw it logs also the context which is also used for the name of the classloader - and has the same issue with "unknown" value - I would like rather to clear it and make it final rather than increasing number of ways to make it "weird".

Copy link
Contributor Author

@OndroMih OndroMih May 7, 2024

Choose a reason for hiding this comment

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

I admit I was just too lazy to look at other places that use the constructor. It's better it all places pass the app name so that it can be in the log.

But I would still turn this log into the DEBUG level. If you think it's essential for development, then we can make the default log configuration set the log level of the org.glassfish.web.loader.WebappClassLoader logger to FINE. But for production, it makes more sense to disable this log with the NORMAL level. Of course, FINE level enables some more log messages, but if they are less important, we can move them to TRACE/FINER level. Would you agree with that?

Copy link
Contributor

Choose a reason for hiding this comment

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

just on CL close.

Maybe we need to look a bit at the wording of the log message too.

I mean, it now sounds like a command.

"Close this: [list]"

Which may make the user wonder if they need to close something explicitly, but they have no idea how to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Basically the important information should be always logged:

  • Name and all endpoints of the application
  • Classpaths
  • When components changed their state, are usable or when they were disabled and why

This reports the classpath of the application. Maybe it would be better to report it on start rather than on close, but because the start is bit more complicated, this is now better.

@OndroMih
Copy link
Contributor Author

I'll close this PR. I see there's no consensus and this change is not important enough to seek for an agreement. I'm OK with logging the full classpath, although I still think it's more a debugging info and it's a noise in normal usage.

@OndroMih OndroMih closed this May 12, 2024
@dmatej
Copy link
Contributor

dmatej commented May 13, 2024

At least you forced me to thing about some future state. @avpinchuk now works on more serious issues with reliable closing applibs (which was never considered on GF and causes IOExceptions on Windows), then I will try to analyze how to move the app name/context name out of the classloader and use the app name as the classloader name instead; and it should be ALWAYS set, so no "unknown" value should be set any more.

And the classpath or cl.toString should be written to logs on startup, not on close. That is still an issue, because of the "lifecycle" which I had to add to force the CL to keep at least some rules. Now we are still expanding the "zone of reliability", so finally it should converge to something more simple.

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.

None yet

3 participants