Open james-z-repo opened 1 year ago
If I understand correctly, what you have tried to do is:
logging-logback
module)By enabling the logging-logback
module, you're saying you want jetty server to use logback to log its events. Therefore, it needs to be able to access a logback configuration file that is on the server classpath, which is why we add the resources/logging-logback.xml
. The module hides the logback classes from the webapp, presumably to allow webapps to provide their own, different logging setup for logs produced by your webapp.
BTW we moved away from configuring server and system classes using explicit jar locations because that's both pretty fragile and too broad - better to be precise about exactly which packages should be excluded from visibility for the webapp.
@joakime any other advice you can give here?
no content
If I understand correctly, what you have tried to do is:
- enable logback logging for the jetty server (by enabling the
logging-logback
module)- provide a logback configuration file that is inside your webapp
By enabling the
logging-logback
module, you're saying you want jetty server to use logback to log its events. Therefore, it needs to be able to access a logback configuration file that is on the server classpath, which is why we add theresources/logging-logback.xml
. The module hides the logback classes from the webapp, presumably to allow webapps to provide their own, different logging setup for logs produced by your webapp.BTW we moved away from configuring server and system classes using explicit jar locations because that's both pretty fragile and too broad - better to be precise about exactly which packages should be excluded from visibility for the webapp.
@joakime any other advice you can give here?
I think I understand what you mean, LOGBACK + Resource/logback.xml is used to override the application's log configuration. But I'm still confused. After I deleted resource/logback.xml, it would be better to load the application configuration instead of the application failing to start.
I think I understand what you mean, LOGBACK + Resource/logback.xml is used to override the application's log configuration.
No, there's a subtlety you're missing. It's not overriding the applications log configuration, the server literally can't see it. You're configuring the server's logging behaviour, not your webapp's logging behaviour.
But I'm still confused. After I deleted resource/logback.xml, it would be better to load the application configuration instead of the application failing to start.
After you deleted resource/logback.xml
, I think you'll find jetty started fine, but your application did not start correctly. If you look at your stacktrace, you can see the exception is in the spring SpringBootServletInitializer
which is looking for logging. It is not finding the ch.qos.logback
classes from the server's classpath because they are hidden from the webapp (by the serverClasses
statement in the logging-logback
module). You'd need to provide your own copy of logback inside your webapp, along with you applications logback.xml config file. Alternatively, if you're trying to have both jetty and your webapp share a common logback setup, have a read of the jetty-9 documentation here: https://eclipse.dev/jetty/documentation/jetty-9/index.html#example-logging-logback-centralized
我想我明白你的意思,LOGBACK + Resource/logback.xml 用于覆盖应用程序的日志配置。 不,你忽略了一个微妙之处。它不会_覆盖_应用程序日志配置,服务器实际上看不到它。您正在配置服务器的日志记录行为,而不是您的网络应用程序的日志记录行为。
但我还是很困惑。我删除resource/logback.xml后,最好加载应用程序配置而不是应用程序无法启动。 删除后
resource/logback.xml
,我想您会发现 jetty 启动正常,但您的应用程序未正确启动。如果您查看堆栈跟踪,您可以看到异常发生在SpringBootServletInitializer
正在寻找日志记录的 spring 中。它没有ch.qos.logback
从服务器的类路径中找到类,因为它们对 web 应用程序是隐藏的(通过模块serverClasses
中的语句logging-logback
)。您需要在 Web 应用程序中提供您自己的 logback 副本以及应用程序 logback.xml 配置文件。或者,如果您想同时拥有码头_和_您的 web 应用程序共享一个通用的 logback 设置,请在此处阅读 jetty-9 文档: https ://eclipse.dev/jetty/documentation/jetty-9/index.html#example-logging-logback-centralized
There is a logback-spring.xml file in my application. According to the logback configuration loading order, it will first search for logback.xml. If this file does not exist, it will load the logback-spring.xml file, because at this time jetty’s addServerClasses leads to I can't load the logback-spring.xml of the application itself as a configuration file, I think this has modified the configuration loading order of logback
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
Jetty version(s)
10.0.15
Jetty Environment
Java version/vendor
(use: java -version)
openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)OS type/version win10
Description
i added module
logging-logback resources
in start.ini deploy a springboot war used logback to write log, i have a normal logback-spring.xml in WEB-INF\classes dir,than i started jetty
1、the E:/TAS_SOFT/jetty-home-10.0.15/logs haven't aaaaa_xxxx file, i think jetty's resources\logback.xml works now 2、when i remove resources/logback.xml i got
i have see etc/logging-logback.mod has the line
but jetty9 logback-impl is:
so' i change jetty10 like this:
then, jetty can load the logback-spring.xml and logs dir has the log file I don't understand why the class path should be used here, not the directory. The class path will work for all applications within JETTY
How to reproduce?