简体   繁体   English

使用java.util.logging在Eclipse服务器端日志中进行GWT开发

[英]GWT development in eclipse server-side logging using java.util.logging

I have been developing my web application using eclipse (4.4) and GWT (2.6.0). 我一直在使用eclipse(4.4)和GWT(2.6.0)开发Web应用程序。 I have an external jar that contains some functionality in pure java, as well as a GWT project that makes use of this jar in the server part (services/servlets). 我有一个包含纯Java中某些功能的外部jar,以及一个在服务器部分(服务/ servlet)中使用此jar的GWT项目。 The GWT project was a pure eclipse project, which I converted at a later point in time to a maven project. GWT项目是一个纯蚀项目,后来我将其转换为maven项目。 The jar is built with maven and populated to the src/main/webapp/WEB-INF/lib/ directory where it works like a charm. 这个jar是用maven构建的,并填充到src / main / webapp / WEB-INF / lib /目录中,在这里它就像一个超级按钮。

Short version: java.util.logging messages generated in the jar or the servlets are being ignored during development instead of being logged to the eclipse console. 简短版:在开发过程中将忽略jar或servlet中生成的java.util.logging消息,而不是将它们记录到eclipse控制台中。

Long version: The logging of messages in the jar and in the GWT servlets is implemented using java.util.logging. 长版:在jar和GWT Servlet中记录消息是使用java.util.logging实现的。 The problem is that during development I am only able to see some messages from the GWT-compilation process and library resolution messages that do not come from the java.util.logging facilities (eg have a DEBUG in them, which does not exist in java.util.logging), but none from my actual code or jar. 问题是,在开发过程中,我只能看到GWT编译过程中的某些消息以及库解析消息,这些消息不是来自java.util.logging工具的(例如,其中包含DEBUG,而Java中不存在) (.util.logging),但没有来自我的实际代码或jar。 When i add the following to the VM arguments in the run configuration of eclipse, I am able to see some info messages from my code, but none of the FINE, FINER, and FINEST levels, as well as none from the jar at all: 当我在eclipse的运行配置中将以下内容添加到VM参数时,我能够从我的代码中看到一些信息消息,但看不到FINE,FINER和FINEST级别,也完全看不到jar中的消息:

-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog -D{classref}.LEVEL=DEBUG

I also tried putting the following logging.properties file in different places, such as src/main/resources, src/main/webapp/WEB-INF/lib/, src/main/webapp/WEB-INF/classes/, but none of the above worked so far. 我还尝试将以下logging.properties文件放在不同的位置,例如src / main / resources,src / main / webapp / WEB-INF / lib /,src / main / webapp / WEB-INF / classes /,但没有到目前为止,以上方法都有效。

handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler

.level= ALL

java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

I haven't deployed the app externally yet, so I don't know how it would behave in eg a Tomcat environment. 我尚未在外部部署该应用程序,因此我不知道它在Tomcat环境中的行为。 The most frustrating thing is that I've been searching on the net for hours, but havent found anything remotely close to the goal of enabling logging and controlling the log levels in my current IDE config. 最令人沮丧的是,我已经在网上搜索了几个小时,但是还没有发现任何东西可以接近在当前IDE配置中启用日志记录和控制日志级别的目标。

Client-side logging from the GWT itself works like a charm. 来自GWT本身的客户端日志记录就像一个魅力。

I would greatly appreciate any help on this topic! 我将非常感谢您对此主题的任何帮助! Thanks in advance :-) 提前致谢 :-)

EDIT: Based on the comments of Joakim Erdfelt and Thomas Broyer, I did an experiment permuting several different Jetty logging parameters which I passed to the VM through the -D argument in the eclipse run configuration (I found them here ). 编辑:基于Joakim Erdfelt和Thomas Broyer的评论,我进行了一个实验,对一些不同的Jetty日志记录参数进行了置换,这些参数是通过Eclipse运行配置中的-D参数传递给VM的(我在这里找到了它们)。

Below are the results. 以下是结果。 The primary goal is to unlock all levels of logging. 主要目标是解锁所有级别的日志记录。

  1. No Jetty logging arguments -> working levels: SEVERE, WARNING, INFO. 没有Jetty日志参数->工作级别:严重,警告,信息。 Complete VM args: 完整的虚拟机参数:

    -Xmx2048m -XstartOnFirstThread -Xmx2048m -XstartOnFirstThread

  2. java.util.logging.config.file (the file is in /src/main/resources/logging.properties, tried src/main/resources/logging.properties, /src/main/resources/logging.properties, logging.properties) -> no level working. java.util.logging.config.file(文件位于/src/main/resources/logging.properties中,尝试过src / main / resources / logging.properties,/ src / main / resources / logging.properties,logging.properties )->没有关卡。

    -Xmx2048m -XstartOnFirstThread -Djava.util.logging.config.file=src/main/resources/logging.properties -Xmx2048m -XstartOnFirstThread -Djava.util.logging.config.file = src / main / resources / logging.properties

  3. -D{classref}.LEVEL=ALL or -D{classref}.LEVEL=FINEST -> working levels: SEVERE, WARNING, INFO. -D{classref}.LEVEL=ALL-D{classref}.LEVEL=FINEST >工作级别:严重,警告,信息。

    -Xmx2048m -XstartOnFirstThread -D{classref}.LEVEL=ALL -Xmx2048m -XstartOnFirstThread -D {classref} .LEVEL = ALL

  4. This also changes nothing. 这也没有改变。 Visible levels are: SEVERE, WARNING, INFO. 可见的级别为:严重,警告,信息。 Complete VM args: 完整的虚拟机参数:

    -Xmx2048m -XstartOnFirstThread -D{classref}.LEVEL=ALL -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StrErrLog -Xmx2048m -XstartOnFirstThread -D {classref} .LEVEL = ALL -Dorg.eclipse.jetty.util.log.class = org.eclipse.jetty.util.log.StrErrLog

So guys, the question is still open. 伙计们,这个问题仍然悬而未决。 Obviously the logging works, however I am unable to set the levels correctly. 显然,日志记录有效,但是我无法正确设置级别。 I must be missing something obvious... 我一定想念一些明显的东西...

Apparently, it is impossible to tell the embedded Jetty of GWT to use the java.util.logging framework in the config I use. 显然,不可能告诉嵌入式GWT Jetty在我使用的配置中使用java.util.logging框架。 I find the decision of the GWT team not to enable this a bit peculiar to say the least, because (an emulation of) the java.util.logging framework is used for the client-side logging. 我发现GWT团队的决定至少要说得有点奇怪,因为java.util.logging框架(的模拟)用于客户端日志记录。 So it would be natural to not mix two different ways of logging in an application and use java.util.logging also for the servlets. 因此,自然不会混合两种不同的登录应用程序的方式,而将java.util.logging也用于servlet。 It is a pity. 很可惜。 Thanks Joakim for pointing this out. 感谢Joakim指出这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM