- 浏览: 32736 次
- 性别:
- 来自: 南京
文章分类
最新评论
-
ccx410:
安装gwt报错,unable to retrieve osgi ...
http://code.google.com/webtoolkit/doc/latest/DevGuideLogging.html
gwt-log http://code.google.com/p/gwt-log/
Adding gwt-log to an (Eclipse) GWT Project
- Download the latest gwt-log-<version>.jar and place it in a convenient location.
- Note for Maven users: Releases are also available in Maven Central with groupId com.allen-sauer.gwt.log and artifact gwt-log.
- Create a GWT Eclipse project as instructed here: http://code.google.com/webtoolkit/usingeclipse.html#creating
- Add the gwt-log jar to your project via one of these two methods:
- Right-click on the project node in the Package Explorer and select 'Build Path > Add External Archives...'. Then, specify the location of the gwt-log-<version>.jar file.
- Copy the gwt-log-<version>.jar file into your project's war/WEB-INF/lib directory. Then, in the Project Explorer view, right click the jar file and select 'Build Path > Add to Build Path'
- Make sure the GWT compiler can find the gwt-log source code. Modify your *.gwt.xml module to include one of the following, depending on your needs:
- (Optional) if you want to play with the demo (examples), you'll need to grab those from the Subversion trunk demo directory as there is no jar file for the demos (i.e. the com.allen_sauer.gwt.log.demo package). See the Using Source with Eclipse wiki for more details.
<!-- For production, most teams prefer to set the default log level to `OFF` --> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <!-- For development, a default of `DEBUG` is recommended --> <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> <!-- To compile at `DEBUG`, `WARN` and `OFF` log levels (with a 3x compile time cost) --> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <extend-property name="log_level" values="DEBUG,WARN"/> <!-- Default to `OFF`, but allow selection of a specific log level, say `INFO`, via the `log_level` URL parameter: http[s]://hostame:port/yourmodule/Yourmodule.html?log_level=INFO --> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <extend-property name="log_level" values="INFO"/> <!-- Compile both `DEBUG` and `ERROR` log levels, with level selection via a `gwt:property` meta tag in your HTML page: <head> <title>....</title> <meta name="gwt:property" content="log_level=DEBUG"> </head> --> <inherits name="com.allen_sauer.gwt.log.gwt-log-ERROR" /> <extend-property name="log_level" values="DEBUG"/>
An Introductory Example
- Use this code in your EntryPoint class:
package com.mycompany.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.allen_sauer.gwt.log.client.Log; /** * Illustrative example. */ public class MyApplication implements EntryPoint { /** * This field gets compiled out when <code>log_level=OFF</code>, or any <code>log_level</code> * higher than <code>DEBUG</code>. */ private long startTimeMillis; /** * Note, we defer all application initialization code to {@link #onModuleLoad2()} so that the * UncaughtExceptionHandler can catch any unexpected exceptions. */ @Override public void onModuleLoad() { /* * Install an UncaughtExceptionHandler which will produce <code>FATAL</code> log messages */ Log.setUncaughtExceptionHandler(); // use deferred command to catch initialization exceptions in onModuleLoad2 Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { onModuleLoad2(); } }); } /** * Deferred initialization method, used by {@link #onModuleLoad()}. */ private void onModuleLoad2() { /* * Use a <code>if (Log.isDebugEnabled()) {...}</code> guard to ensure that * <code>System.currentTimeMillis()</code> is compiled out when <code>log_level=OFF</code>, or * any <code>log_level</code> higher than <code>DEBUG</code>. */ if (Log.isDebugEnabled()) { startTimeMillis = System.currentTimeMillis(); } /* * No guards necessary. Code will be compiled out when <code>log_level=OFF</code> */ Log.debug("This is a 'DEBUG' test message"); Log.info("This is a 'INFO' test message"); Log.warn("This is a 'WARN' test message"); Log.error("This is a 'ERROR' test message"); Log.fatal("This is a 'FATAL' test message"); Log.fatal("This is what an exception might look like", new RuntimeException("2 + 2 = 5")); Log.debug("foo.bar.baz", "Using logging categories", (Exception) null); /* * Again, we need a guard here, otherwise <code>log_level=OFF</code> would still produce the * following useless JavaScript: <pre> var durationSeconds, endTimeMillis; endTimeMillis = * currentTimeMillis_0(); durationSeconds = (endTimeMillis - this$static.startTimeMillis) / * 1000.0; </pre> */ if (Log.isDebugEnabled()) { long endTimeMillis = System.currentTimeMillis(); float durationSeconds = (endTimeMillis - startTimeMillis) / 1000F; Log.debug("Duration: " + durationSeconds + " seconds"); } } }
Other things you might want to do
Dynamically adjust the runtime log level
Log.setCurrentLogLevel(Log.LOG_LEVEL_...);
Get the floating DivLogger out of your way
Disable the DivLogger:
<set-property name="log_DivLogger" value="DISABLED" />
Or place it at a fixed location in your appliation:
Widget divLogger = Log.getLogger(DivLogger.class).getWidget(); someWidgetOfYours.add(divLogger);
Enable the remote logging option (disabled by default)
Enabling the remote logging option sends copies of all client log messages to the server where it can be written to a file. This is particularly useful for mobile development. Modify your module file:
<!-- In gwt-log-3.0.3 or later --> <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" /> <!-- In gwt-log-3.0.2 or earlier releases only, use this instead --> <set-property name="log_RemoteLogger" value="ENABLED" />
To deploy the RemoteLogger to your own web server:
- Compile your application with -deploy war/WEB-INF/deploy/, so that the GWT compiler produces symbolsMaps, which gwt-log can use for deobfuscation of stack traces
- Include the remote logger servlet in your web.xml deployment descriptor:
<servlet> <servlet-name>gwt-log-remote-logger-servlet</servlet-name> <servlet-class>com.allen_sauer.gwt.log.server.RemoteLoggerServiceImpl</servlet-class> <!-- symbolMaps param provides for stack trace deobfuscation --> <init-param> <param-name>symbolMaps</param-name> <!-- This value assumes a GWT compile with '-deploy war/WEB-INF/deploy/' --> <param-value>WEB-INF/deploy/your-module-name/symbolMaps/</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>gwt-log-remote-logger-servlet</servlet-name> <url-pattern>/your-module-name/gwt-log</url-pattern> </servlet-mapping>
- The default JDK logging level is INFO, i.e. in java.util.logging terms, FINEST, FINER, FINE, CONFIG are ignored and only INFO, WARNING, SEVERE are logged. See JDK_HOME/jre/lib/logging.properties.
- The default JDK logging level can be set in your logging.properties file:
# Set the default for all loggers to log everything .level = ALL
- The default log4j logging level is DEBUG, i.e. TRACE messages are ignored while DEBUG, INFO, WARN, ERROR, FATAL are logged. This can be controlled via log4j.xml or log4j.properties.
- Note: on Google App Engine, log4j uses JDK logging, even when a log4j jar is present on the server classpath. This provides for better integration with the App Engine admin console.
Turn on the experimental WindowLogger
The experimental WindowLogger (disabled by default), can log messages to a separate window, so that logging does not affect the DOM in your application.
<!-- Enable experimental WindowLogger, which logs messages to a separate popup window. There are currently a couple of restrictions: 1. When Firefox is configured to open new Windows as new tabs, WindowLogger does not work 2. In GWT Development Mode, the windows are not automatically closed, although you can easily close them manually in the usual way --> <set-property name="log_WindowLogger" value="ENABLED" /> <!-- You'll probably want to disable the default `DivLogger` as well: --> <set-property name="log_DivLogger" value="DISABLED" />
Control which loggers are active
<!-- Loggers Enabled by default --> <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_DivLogger" value="ENABLED" /> <set-property name="log_FirebugLogger" value="ENABLED" /> <set-property name="log_GWTLogger" value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED" /> <!-- Loggers Disabled by default --> <set-property name="log_WindowLogger" value="DISABLED" /> <!-- In gwt-log-3.0.3 or later, enable RemoteLogger with --> <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" />
Control the format of your log messages
<!-- Inspired by Apache log4j PatternLayout: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html --> <set-configuration-property name="log_pattern" value="(%F:%L) %d [%-5p] %m%n" />
Adjust the z-index of the DivLogger panel
- Review the gwt-log.css file to see the CSS which is injected into your application by gwt-log.
- Override the z-index (using !important if necessary) by adding a new rule to your application's CSS:
.log-panel { z-index: 2000; }
or:
.log-panel { z-index: 2000 !important; }
Override the default URL which the RemoteLogger connects to
The default RemoteLogger URL can be set via the log_url property:
<set-configuration-property name="log_url" value="/my-custom-servlet-url" />
Don't forget to make a corresponding change to your web.xml.
Configuring multiple .gwt.xml module files
Advanced projects may have more than one .gwt.xml module files which inherit from each other.
An initial module file may wish to set logging OFF by default:
<inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" />
A later module file may wish to override this and enable say DEBUG logging:
<extend-property name="log_level" values="DEBUG"/> <set-property name="log_level" value="DEBUG"/>
Setup an UncaughtExceptionHandler
Setting up an UncaughtExceptionHandler is as easy as calling Log.setUncaughtExceptionHandler() before you do anything else in your module.
@Override public void onModuleLoad() { /* * Install an UncaughtExceptionHandler which will produce <code>FATAL</code> log messages */ Log.setUncaughtExceptionHandler(); // use deferred command to catch initialization exceptions in onModuleLoad2 Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { onModuleLoad2(); } }); } private void onModuleLoad2() { // Your client code goes here }
Note that we use a deferred command and void any initialization code during our EntryPoint class loading or construction. This ensures that we really catch everything in Production Mode. In Chrome, Firefox and IE this will even catch exceptions thrown from JSNI via setTimeout() or setInterval() functions.
Use logging categories
Using categories from your code
The default logging category for all log messages is gwt-log (and not, say, com.allen_sauer.gwt.log.gwt-log).
Use the three argument logging methods to override the default logging category:
Log.debug("com.foo.myproject.mycategory", "2 + 2 = 5, for large values of two", exception);
Client side category logging
Include a category specifier %c in your log_pattern:
<set-configuration-property name="log_pattern" value="[%c] (%F:%L) %d [%-5p] %m%n" />
Server side category logging, when using java.util.logging (which is the default)
You'll need to modify the default java.util.logging.Formatter:
package myapp.server; import java.util.logging.Formatter; import java.util.logging.Handler; import java.util.logging.LogRecord; import java.util.logging.Logger; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; public class MyContextListener implements ServletContextListener { private Formatter formatter = new Formatter() { @Override public String format(LogRecord record) { return "(" + record.getLoggerName() + ") " + super.formatMessage(record); } }; @Override public void contextDestroyed(ServletContextEvent evt) { // do nothing } @Override public void contextInitialized(ServletContextEvent evt) { Logger rootLogger = Logger.getLogger(""); // crude replacement of existing formatters for (Handler handler : rootLogger.getHandlers()) { handler.setFormatter(formatter); } } }
Modify your WEB-INF/web.xml to ensure your changes are installed when your application starts:
<listener> <listener-class>logcat.server.MyContextListener</listener-class> </listener>
Server side category logging, when using log4j
Use the standard log4j methods to configure a PatternLayout. This commonly done via a log4j.properties or log4j.xml file.
Get more our of gwt-log
- Add logging to your serializable domain objects, POJOs, etc. for both client and server side logging
- In development you likely want to use -style PRETTY rather than the default -style OBFUSCATED in order to get better Production Mode stack trace methods.
- When developing, you may wish to turn on enhanced Production Mode stack traces. Note this adds overhead to the resulting JavaScript so you generally don't want to leave this on for production. Then again, if you're debugging a production issue, you might need to anyway :)
- Use gwt-log seemlessly on Google App Engine
- Modify your logging.properties file:
.level = FINEST
<set-property name="compiler.emulatedStack" value="true" /> <set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/> <set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>
Working Examples
There are some working examples along with the demo source code for you to look at.
There's also the library source code if you want to see what makes it tick.
-
Download the latest gwt-log-<version>.jar and place it in a convenient location.下载最新GWT日志- <版本>。JAR和它放置在一个方便的位置。
- Note for Maven users: Releases are also available in Maven Central with groupId com.allen-sauer.gwt.log and artifact gwt-log . Maven用户注意:发布也可用的Maven中央的groupId com.allen sauer.gwt.log和神器GWT日志。
- Create a GWT Eclipse project as instructed here: http://code.google.com/webtoolkit/usingeclipse.html#creating创建一个GWT的Eclipse项目的指示: http://code.google.com/webtoolkit/usingeclipse.html#创建
-
Add the gwt-log jar to your project via one of these two methods: GWT日志JAR添加到您的项目中,通过这两种方法之一:
- Right-click on the project node in the Package Explorer and select 'Build Path > Add External Archives...'.在Package Explorer中的项目节点上右键单击,并选择“构建路径>添加外部档案...'. Then, specify the location of the gwt-log-<version>.jar file.然后,指定GWT日志<版本>。jar文件的位置。
- Copy the gwt-log-<version>.jar file into your project's war/WEB-INF/lib directory. GWT日志<版本>。jar文件复制到项目的战争/ WEB - INF / lib目录。 Then, in the Project Explorer view, right click the jar file and select 'Build Path > Add to Build Path'然后,在Project Explorer视图中,右键点击JAR文件,并选择“构建路径>添加到构建路径”
-
Make sure the GWT compiler can find the gwt-log source code.确保GWT编译器可以找到GWT的日志源代码。 Modify your *.gwt.xml module to include one of the following, depending on your needs:修改您的*. gwt.xml模块之一以下,根据您的需要,包括:
<!-- For production, most teams prefer to set the default log level to `OFF` --> <! - 生产,大多数球队喜欢默认的日志级别设置'关' - > <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <!-- For development, a default of `DEBUG` is recommended --> <! - 发展,建议`调试`默认 - > <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> <!-- To compile at `DEBUG`, `WARN` and `OFF` log levels (with a 3x compile time cost) --> <! - 要编译`DEBUG`,`WARN'和'关'的日志级别(用3倍的编译时间成本) - > <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <extend-property name="log_level" values="DEBUG,WARN"/> <extend-property name="log_level" values="DEBUG,WARN"/> <!-- <! - Default to `OFF`, but allow selection of a specific log level,默认为'关',但允许选择一个特定的日志级别, say `INFO`, via the `log_level` URL parameter:说`信息`通过`LOG_LEVEL URL参数: http[s]://hostame:port/yourmodule/Yourmodule.html?log_level=INFO HTTP [S]:/ / hostame:端口/ yourmodule / Yourmodule.html LOG_LEVEL =信息 --> - > <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <extend-property name="log_level" values="INFO"/> <extend-property name="log_level" values="INFO"/> <!-- <! - Compile both `DEBUG` and `ERROR` log levels, with level编译两个'调试'和'错误'的日志级别,同级别 selection via a `gwt:property` meta tag in your HTML page:通过`GWT:物业`在你的HTML页面的meta标签的选择: <head> <HEAD> <title>....</title> <TITLE> ....</标题> <meta name="gwt:property" content="log_level=DEBUG"> <meta name="gwt:property" content="log_level=DEBUG"> </head> </ HEAD> --> - > <inherits name="com.allen_sauer.gwt.log.gwt-log-ERROR" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-ERROR" /> <extend-property name="log_level" values="DEBUG"/> <extend-property name="log_level" values="DEBUG"/>
- (Optional) if you want to play with the demo (examples), you'll need to grab those from the Subversion trunk demo directory as there is no jar file for the demos (ie the com.allen_sauer.gwt.log.demo package). (可选)如果你要播放的演示(范例),您将需要抓住那些从Subversion的躯干demo目录有没有jar文件的演示(即com.allen_sauer.gwt.log.demo包)。 See the Using Source with Eclipse wiki for more details.请参阅使用源与 Eclipse wiki的更多细节。
An Introductory Example介绍例题
-
Use this code in your EntryPoint class:使用此代码在您的EntryPoint类:
package com.mycompany.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.allen_sauer.gwt.log.client.Log; /** * Illustrative example.包com.mycompany.client进口com.google.gwt.core.client.EntryPoint,进口com.google.gwt.core.client.Scheduler,进口com.google.gwt.core.client.Scheduler.ScheduledCommand,进口COM 。allen_sauer.gwt.log.client.Log; / ** *例证。 */ public class MyApplication implements EntryPoint { /** * This field gets compiled out when <code>log_level=OFF</code>, or any <code>log_level</code> * higher than <code>DEBUG</code>. * /公共类MyApplication的实现的EntryPoint {/ ** *此字段被编译出来的<code> LOG_LEVEL = OFF </代码>,或任何<code> LOG_LEVEL </代码> *比<CODE> DEBUG </ CODE>更高。 */ private long startTimeMillis; /** * Note, we defer all application initialization code to {@link #onModuleLoad2()} so that the * UncaughtExceptionHandler can catch any unexpected exceptions. * /私人长期startTimeMillis; / ** *注意,我们推迟了所有应用程序初始化代码{@链接#onModuleLoad2()} * UncaughtExceptionHandler可以捕获任何意外的异常。 */ @Override public void onModuleLoad() { /* * Install an UncaughtExceptionHandler which will produce <code>FATAL</code> log messages */ Log.setUncaughtExceptionHandler(); // use deferred command to catch initialization exceptions in onModuleLoad2 Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { onModuleLoad2(); } }); } /** * Deferred initialization method, used by {@link #onModuleLoad()}. * / @覆盖公共无效onModuleLoad(){/ * *安装UncaughtExceptionHandler将产生<CODE>致命</代码>日志消息* / Log.setUncaughtExceptionHandler(); / /使用递延onModuleLoad2调度命令赶上初始化例外。 (新ScheduledCommand()()scheduleDeferred {@覆盖公共无效的execute(){onModuleLoad2();}});} / ** *递延初始化的方法,使用的{@ link#onModuleLoad()}。 */ private void onModuleLoad2() { /* * Use a <code>if (Log.isDebugEnabled()) {...}</code> guard to ensure that * <code>System.currentTimeMillis()</code> is compiled out when <code>log_level=OFF</code>, or * any <code>log_level</code> higher than <code>DEBUG</code>. * /私人无效onModuleLoad2(){/ * *使用一个<code>(Log.isDebugEnabled()){...}</代码>后卫,以确保*的<code>()</代码>编译的<code> LOG_LEVEL = OFF </代码>,或任何<code> LOG_LEVEL </代码>高于<CODE>调试</代码>。 */ if (Log.isDebugEnabled()) { startTimeMillis = System.currentTimeMillis(); } /* * No guards necessary. * /如果(Log.isDebugEnabled()){startTimeMillis = System.currentTimeMillis的();} / *没有卫兵必要的。 Code will be compiled out when <code>log_level=OFF</code> */ Log.debug("This is a 'DEBUG' test message"); Log.info("This is a 'INFO' test message"); Log.warn("This is a 'WARN' test message"); Log.error("This is a 'ERROR' test message"); Log.fatal("This is a 'FATAL' test message"); Log.fatal("This is what an exception might look like", new RuntimeException("2 + 2 = 5")); Log.debug("foo.bar.baz", "Using logging categories", (Exception) null); /* * Again, we need a guard here, otherwise <code>log_level=OFF</code> would still produce the * following useless JavaScript: <pre> var durationSeconds, endTimeMillis; endTimeMillis = * currentTimeMillis_0(); durationSeconds = (endTimeMillis - this$static.startTimeMillis) / * 1000.0; </pre> */ if (Log.isDebugEnabled()) { long endTimeMillis = System.currentTimeMillis(); float durationSeconds = (endTimeMillis - startTimeMillis) / 1000F; Log.debug("Duration: " + durationSeconds + " seconds"); } } }代码将被编译出来的<code> LOG_LEVEL = OFF </代码> * / Log.debug(“这是一个”调试“测试邮件”); Log.info(“这是一个”信息“测试邮件”); Log.warn(“这是一个”WARN“测试消息”); Log.error(“这是一个”错误“测试消息”); Log.fatal(“这是一个”致命“的测试消息”);日志。致命的(“这是一个异常可能看起来像”,新的RuntimeException(“2 +2 = 5”)); Log.debug(“foo.bar.baz”,“使用日志记录类别”,(例外)NULL); / *同样,我们需要一个后卫,否则<CODE> LOG_LEVEL = OFF </代码>仍然会产生以下无用的JavaScript *:<PRE> VAR durationSeconds,endTimeMillis; endTimeMillis = * currentTimeMillis_0(); durationSeconds =(endTimeMillis - 这static.startTimeMillis)/ * 1000.0; </ PRE> * /如果(Log.isDebugEnabled()){长endTimeMillis =();浮动durationSeconds =(endTimeMillis - startTimeMillis)/ 1000F; Log.debug( “时间:”+ durationSeconds +“秒”);}}}
Other things you might want to do其他的事情,你可能想这样做
Dynamically adjust the runtime log level动态调整运行时的日志级别
Log.setCurrentLogLevel(Log.LOG_LEVEL_...); Log.setCurrentLogLevel(Log.LOG_LEVEL_ ...);
Get the floating DivLogger out of your way走出自己的方式浮动DivLogger
Disable the DivLogger :禁用DivLogger:
<set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED"
Or place it at a fixed location in your appliation:或在固定的位置,在您的appliation:
Widget divLogger = Log.getLogger(DivLogger.class).getWidget();部件divLogger = Log.getLogger(DivLogger.class)getWidget(); someWidgetOfYours.add(divLogger); someWidgetOfYours.add(divLogger);
Enable the remote logging option (disabled by default)启用远程登录选项(默认情况下禁用)
Enabling the remote logging option sends copies of all client log messages to the server where it can be written to a file.启用“远程登录”选项,所有客户端日志消息的副本发送到可以写入到文件服务器。 This is particularly useful for mobile development.这是移动开发特别有用。 Modify your module file:修改你的模块文件:
<!-- In gwt-log-3.0.3 or later --> <! - 在GWT日志3.0.3或更高版本 - > <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" /> <!-- In gwt-log-3.0.2 or earlier releases only, use this instead --> <! - 只有在GWT日志3.0.2或更早版本,使用这个,而不是 - > <set-property name="log_RemoteLogger" value="ENABLED" /> <set-property name="log_RemoteLogger" value="ENABLED"
To deploy the RemoteLogger to your own web server:要部署自己的Web服务器RemoteLogger:
- Compile your application with -deploy war/WEB-INF/deploy/ , so that the GWT compiler produces symbolsMaps, which gwt-log can use for deobfuscation of stack traces编译您的应用程序与部署战争/ WEB - INF /部署/,让GWT编译器产生symbolsMaps,GWT日志可以使用堆栈跟踪deobfuscation
-
Include the remote logger servlet in your web.xml deployment descriptor:在你的web.xml部署描述符中包含的远程记录器的servlet:
<servlet>的<servlet> <servlet-name>gwt-log-remote-logger-servlet</servlet-name> <servlet-name> GWT日志,远程记录器的servlet </ servlet的名称> <servlet-class>com.allen_sauer.gwt.log.server.RemoteLoggerServiceImpl</servlet-class> <servlet-class> com.allen_sauer.gwt.log.server.RemoteLoggerServiceImpl </ servlet的类> <!-- symbolMaps param provides for stack trace deobfuscation --> <! - symbolMaps参数堆栈跟踪deobfuscation提供 - > <init-param> <init-param> <param-name>symbolMaps</param-name> <param-name> symbolMaps </的param - name> <!-- This value assumes a GWT compile with '-deploy war/WEB-INF/deploy/' --> <! - 此值假定与战争“的部署/ WEB - INF /部署/'一个GWT编译 - > <param-value>WEB-INF/deploy/your-module-name/symbolMaps/</param-value> <param-value> WEB-INF/deploy/your-module-name/symbolMaps / </参数值> </init-param> </的init - param> </servlet> </ servlet的> <servlet-mapping> <servlet-mapping> <servlet-name>gwt-log-remote-logger-servlet</servlet-name> <servlet-name> GWT日志,远程记录器的servlet </ servlet的名称> <url-pattern>/your-module-name/gwt-log</url-pattern> <url-pattern> / your-module-name/gwt-log </的url - pattern> </servlet-mapping> </ servlet的映射>
- Don't forget to include gwt-log-xxxjar in the server classpath, which usually means dropping the jar file into war/WEB-INF/lib/ .不要忘了,包括GWT日志xxxjar在服务器类路径,这通常意味着战争/ WEB - INF / lib中/ jar文件拖放到。 In Eclipse, also right click on the jar and select Build Path -> Add to Build Path .在Eclipse中,也是正确的jar点击并选择“ 构建路径- >添加到构建路径 。
-
If you're using java.util.logging (the default), you can configure Java Logging .如果你使用的java.util.logging(默认),你可以配置Java记录 。
- The default JDK logging level is INFO , ie in java.util.logging terms, FINEST , FINER , FINE , CONFIG are ignored and only INFO , WARNING , SEVERE are logged.默认的JDK日志记录级别是 INFO, 即 java.util.logging中的条款 ,最好的,FINER,罚款,CONFIG,被忽略,只有信息 , 警告,重度记录。 See JDK_HOME/jre/lib/logging.properties . JDK_HOME /的jre / lib / logging.properties。
-
The default JDK logging level can be set in your logging.properties file: logging.properties文件中可以设置默认的JDK日志记录级别:
# Set the default for all loggers to log everything #设置所有记录器的默认登录的一切 .level = ALL 。水平= ALL,
-
If you prefer to use log4j, you may also optionally drop a log4j jar file on the server side classpath (again, usually war/WEB-INF/lib/ ), in which case gwt-log will use log4j logging instead of java.util.logging` based logging如果你喜欢使用log4j,你也可以选择性地砸在服务器端的classpath一个Log4j的jar文件 (通常战争/ WEB - INF / LIB /),在这种情况下,GWT日志将使用log4j日志,而不是java.util的。测井`基于日志
- The default log4j logging level is DEBUG , ie TRACE messages are ignored while DEBUG , INFO , WARN , ERROR , FATAL are logged.默认的log4j日志级别是 DEBUG, 即跟踪消息被忽略,而DEBUG,INFO,WARN,ERROR,致命的记录。 This can be controlled via log4j.xml or log4j.properties .这可以通过控制的log4j.xml或log4j.properties文件 。
- Note: on Google App Engine, log4j uses JDK logging, even when a log4j jar is present on the server classpath.注:谷歌应用程序引擎,log4j的使用JDK日志,甚至当一个Log4j的jar服务器类路径上。 This provides for better integration with the App Engine admin console.这为更好地整合与App Engine的管理控制台。
Turn on the experimental WindowLogger打开实验WindowLogger
The experimental WindowLogger (disabled by default), can log messages to a separate window, so that logging does not affect the DOM in your application.实验WindowLogger(默认禁用),消息记录到一个单独的窗口,因此,日志记录,不影响应用程序中的DOM。
<!-- <! - Enable experimental WindowLogger, which logs messages to a separate启用的实验WindowLogger,消息记录到一个单独的 popup window.弹出窗口。 There are currently a couple of restrictions:目前有几个限制: 1. 1。 When Firefox is configured to open new Windows as new tabs,当Firefox配置新的窗口打开新的标签, WindowLogger does not work WindowLogger并没有工作 2. 2。 In GWT Development Mode, the windows are not automatically closed,在GWT开发模式下,窗口不会自动关闭, although you can easily close them manually in the usual way虽然您可以轻松地关闭它们通常的方式手动 --> - > <set-property name="log_WindowLogger" value="ENABLED" /> <set-property name="log_WindowLogger" value="ENABLED" <!-- <! - You'll probably want to disable the default `DivLogger` as well:您可能要禁用默认的`DivLogger以及: --> - > <set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED"
Control which loggers are active控制记录仪活动
<!-- Loggers Enabled by default --> <! - 默认情况下启用的记录器 - > <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_ConsoleLogger" value="ENABLED" <set-property name="log_DivLogger" value="ENABLED" /> <set-property name="log_DivLogger" value="ENABLED" <set-property name="log_FirebugLogger" value="ENABLED" /> <set-property name="log_FirebugLogger" value="ENABLED" <set-property name="log_GWTLogger" value="ENABLED" /> <set-property name="log_GWTLogger" value="ENABLED" <set-property name="log_SystemLogger" value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED" <!-- Loggers Disabled by default --> <! - 默认情况下禁用记录器 - > <set-property name="log_WindowLogger" value="DISABLED" /> <set-property name="log_WindowLogger" value="DISABLED" <!-- In gwt-log-3.0.3 or later, enable RemoteLogger with --> <! - GWT日志3.0.3或更高版本,使RemoteLogger与 - > <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" />
Control the format of your log messages控制日志消息的格式
<!-- <! - Inspired by Apache log4j PatternLayout:灵感来自于Apache的log4j的PatternLayout: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html --> - > <set-configuration-property name="log_pattern" value="(%F:%L) %d [%-5p] %m%n" /> <set-configuration-property name="log_pattern" value="(%F:%L) %d [%-5p] %m%n" />
Adjust the z-index of the DivLogger panel调整的z - index的DivLogger面板
- Review the gwt-log.css file to see the CSS which is injected into your application by gwt-log.查看GWT log.css文件看到,这是注射到您的应用程序日志GWT的CSS。
-
Override the z-index (using !important if necessary) by adding a new rule to your application's CSS:一个新的规则加入到应用程序的CSS覆盖的z - index(使用重要的,如果必要的!):
.log-panel { 。日志,面板{ z-index: 2000;的z - index:2000; } }
or:或:
.log-panel { 。日志,面板{ z-index: 2000 !important;的z - index:2000年重要的; } }
Override the default URL which the RemoteLogger connects to覆盖默认的URL RemoteLogger连接
The default RemoteLogger URL can be set via the log_url property:通过log_url属性可以设置默认的RemoteLogger URL:
<set-configuration-property name="log_url" value="/my-custom-servlet-url" /> <set-configuration-property name="log_url" value="/my-custom-servlet-url"
Don't forget to make a corresponding change to your web.xml .不要忘记你的web.xml中作出相应的改变。
Configuring multiple .gwt.xml module files配置多个。gwt.xml模块文件
Advanced projects may have more than one .gwt.xml module files which inherit from each other.先进的项目可能有多个。gwt.xml模块文件相互继承。
An initial module file may wish to set logging OFF by default:一个初步的模块文件,不妨设置默认为关闭登录:
<inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" />
A later module file may wish to override this and enable say DEBUG logging:后来的模块文件可能希望重写此方法,并使说调试日志记录:
<extend-property name="log_level" values="DEBUG"/> <extend-property name="log_level" values="DEBUG"/> <set-property name="log_level" value="DEBUG"/> <set-property name="log_level" value="DEBUG"/>
Setup an UncaughtExceptionHandler设定一个UncaughtExceptionHandler
Setting up an UncaughtExceptionHandler is as easy as calling Log.setUncaughtExceptionHandler() before you do anything else in your module.设置UncaughtExceptionHandler Log.setUncaughtExceptionHandler()调用之前,你做任何其他模块中的容易。
@Override @覆盖 public void onModuleLoad() {公共无效onModuleLoad(){ /* / * * Install an UncaughtExceptionHandler which will produce <code>FATAL</code> log messages *安装UncaughtExceptionHandler将产生<CODE>致命</ code>的日志消息 */ * / Log.setUncaughtExceptionHandler(); Log.setUncaughtExceptionHandler(); // use deferred command to catch initialization exceptions in onModuleLoad2 / /使用递延命令赶上onModuleLoad2初始化例外 Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get()。scheduleDeferred(新ScheduledCommand(){ @Override @覆盖 public void execute() {公共无效的execute(){ onModuleLoad2(); onModuleLoad2(); } } }); }); } } private void onModuleLoad2() {私人无效onModuleLoad2(){ // Your client code goes here / /客户端代码放在这里 } }
Note that we use a deferred command and void any initialization code during our EntryPoint class loading or construction.注意,我们使用一个延迟命令无效任何初始化代码在我们的EntryPoint类装载或建设。 This ensures that we really catch everything in Production Mode.这将确保我们真的赶在生产模式下的一切。 In Chrome, Firefox and IE this will even catch exceptions thrown from JSNI via setTimeout() or setInterval() functions.在Chrome,Firefox和IE,甚至会赶上从JSNI 通过的setTimeout()或setInterval()函数抛出的异常。
Use logging categories使用日志记录类别
Using categories from your code从你的代码中使用类别
The default logging category for all log messages is gwt-log (and not , say, com.allen_sauer.gwt.log.gwt-log ).默认日志记录类别的所有日志消息GWT日志 (而不是说,com.allen_sauer.gwt.log.gwt日志 )。
Use the three argument logging methods to override the default logging category:使用三个参数测井方法来覆盖默认的日志记录类别:
Log.debug("com.foo.myproject.mycategory", "2 + 2 = 5, for large values of two", exception); Log.debug(“com.foo.myproject.mycategory”,“2 +2 = 5,两个大值”,异常);
Client side category logging客户端类别的日志记录
Include a category specifier %c in your log_pattern :包括在您log_pattern的类别说明符 % C:
<set-configuration-property name="log_pattern" value="[%c] (%F:%L) %d [%-5p] %m%n" /> <set-configuration-property name="log_pattern" value="[%c] (%F:%L) %d [%-5p] %m%n" />
Server side category logging, when using java.util.logging (which is the default)服务器端类别的日志记录,当使用java.util.logging的 (这是默认设置)
You'll need to modify the default java.util.logging.Formatter :你需要修改默认的java.util.logging.Formatter:
package myapp.server;包myapp.server; import java.util.logging.Formatter;进口java.util.logging.Formatter; import java.util.logging.Handler;进口java.util.logging.Handler; import java.util.logging.LogRecord;进口java.util.logging.LogRecord; import java.util.logging.Logger;进口java.util.logging.Logger; import javax.servlet.ServletContextEvent;进口javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener;进口javax.servlet.ServletContextListener; public class MyContextListener implements ServletContextListener {公共类MyContextListener实现ServletContextListener { private Formatter formatter = new Formatter() {格式化格式化新的Formatter(){ @Override @覆盖 public String format(LogRecord record) {公共字符串格式(LogRecord是否记录){ return "(" + record.getLoggerName() + ") " + super.formatMessage(record);回归“(”+ record.getLoggerName()+“)”super.formatMessage(记录); } } }; }; @Override @覆盖 public void contextDestroyed(ServletContextEvent evt) {公共无效contextDestroyed(ServletContextEvent EVT){ // do nothing / /什么也不做 } } @Override @覆盖 public void contextInitialized(ServletContextEvent evt) {公共无效contextInitialized(ServletContextEvent EVT){ Logger rootLogger = Logger.getLogger("");记录器rootLogger = Logger.getLogger (""); // crude replacement of existing formatters / /原油更换现有的格式化 for (Handler handler : rootLogger.getHandlers()) { (处理程序处理程序:rootLogger.getHandlers()){ handler.setFormatter(formatter); handler.setFormatter(格式化); } } } } } }
Modify your WEB-INF/web.xml to ensure your changes are installed when your application starts:您的WEB-INF/web.xml中修改,以确保您的应用程序启动时,您所做的更改安装:
<listener>的<listener> <listener-class>logcat.server.MyContextListener</listener-class> <listener-class> logcat.server.MyContextListener </监听级> </listener> </监听器>
Server side category logging, when using log4j服务器端类别的日志记录,当使用log4j
Use the standard log4j methods to configure a PatternLayout .使用标准log4j的方法来配置一个 PatternLayout 。 This commonly done via a log4j.properties or log4j.xml file.这通常都是通过一个 log4j.properties或log4j.xml文件。
Get more our of gwt-log获取更多的GWT日志
- Add logging to your serializable domain objects, POJOs, etc. for both client and server side logging添加客户端和服务器端日志记录可序列化域对象,POJO的等。
- In development you likely want to use -style PRETTY rather than the default -style OBFUSCATED in order to get better Production Mode stack trace methods.在发展中,你可能想使用风格的漂亮,而不是默认的风格混淆,以获得更好的生产模式堆栈跟踪方法。
-
When developing, you may wish to turn on enhanced Production Mode stack traces.开发时,你不妨把提高生产模式堆栈跟踪。 Note this adds overhead to the resulting JavaScript so you generally don't want to leave this on for production.请注意这会增加开销所产生的JavaScript,所以你不想留在这个生产。 Then again, if you're debugging a production issue, you might need to anyway :)话又说回来,如果你调试的生产问题,你可能需要反正:)
<set-property name="compiler.emulatedStack" value="true" /> <set-property name="compiler.emulatedStack" value="true" /> <set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/> <set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/> <set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/> <set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>
-
Use gwt-log seemlessly on Google App Engine使用GWT编写日志上谷歌的App Engine
-
Modify your logging.properties file:修改您的logging.properties文件:
.level = FINEST 。水平= FINEST
-
Modify your logging.properties file:修改您的logging.properties文件:
Working Examples工作示例
There are some working examples along with the demo source code for you to look at.有一些工作的例子 演示的源代码 ,你看看。
There's also the library source code if you want to see what makes it tick.还有库的源代码 ,如果你想看到什么使得它。
- gwt-log-3.1.5.jar (150.2 KB)
- 下载次数: 0
- gwt-log-3.1.5-javadoc.jar (187.1 KB)
- 下载次数: 0
- gwt-log-3.1.5.jar (150.2 KB)
- 下载次数: 2
相关推荐
“http://code.google.com/p/google-gin/wiki/GinTutorial”指向的是Google Gin的一个教程。Gin是Google开发的一个轻量级依赖注入(DI)框架,它是基于Guice的,用于简化GWT应用中的依赖管理。Guice是一个面向Java的...
组件用Java编写生成所有 javascript (v1.4) 的Google Web Toolkit RDF 数据库(Jena v2.5.5) Dojo在所有浏览器中绘制 SVG/VML 线 (v1.0.2)概念http://gwt.org.ua/odbui/manual/fluxb_layout.html 现场演示...
原地址如下 http://google-web-toolkit.googlecode.com/files/gwt-dev-plugin-1.26-rc1.xpi
Online TGA Canvas Demo page is http://npe-net.appspot.com/npesdk/gwt/tgaimagedemo/index.html Online TGA WebGL Texture Demo page is http://npe-net.appspot.com/npesdk/gwt/tgawebgldemo/index.html ...
gwt-site, gwtproject.org 网站的网页来源 文档GWT文档是在 http://www.gwtproject.org/doc/latest/DevGuide.html 发布的。引用Markdown 处理器:https://github.com/sirthias/pegdow
Sitemaps / GWT / GA Chapter 30. Part #4 – User Interaction Ranking Strategies Chapter 31. Engagement Is Key Chapter 32. Ad Placement Can Seriously Hurt You Chapter 33. Part #5 - Off Page / ...
【标题】"java6.0源码-quake2-gwt-port:从code.google.com/p/quake2-gwt-port自动导出" 涉及的是一个Java 6版本的开源项目,名为Quake2-GWT-Port,它是经典游戏Quake 2的一个Web版本实现,利用了Google Web Toolkit ...
gwt-2.5.1—part1.rar part2:http://download.csdn.net/detail/u011029071/5992583
从 code.google.com/p/gwt-crypto 自动导出 ===更新 2015-03-12:=== 嗨伙计, 鉴于即将关闭的谷歌代码: : 我将其移至 github: : 我不再支持这个项目了,所以请随意分叉! 担 Brill 说:在 GWT 论坛中,有人...
java播放器源码瓷砖 Java、GWT 和 C++ 带有用于自动拼字游戏的 protobuf。 应用于解决拼字游戏的通用搜索运算符。 词选择的优化可以使用键匹配应用程序,以及组合优化和启发式方法。..../a.out -d dic
GWT-OAuth2 是一个基于 Google Web Toolkit (GWT) 的库,用于在 GWT 应用程序中实现 OAuth 2.0 身份验证。OAuth 2.0 是一个授权框架,允许第三方应用安全地访问用户的受保护资源,而无需获取其登录凭据。GWT 是一个...
gwt-maven-plugin 该插件旨在通过提供两种特定的打包方式: gwt-lib和gwt-app ,使使用Maven构建GWT项目更加容易。 基本用法 将插件添加到您的POM并启用扩展: < groupId>net.ltgt.gwt.maven</ groupId> ...
从 code.google.com/p/gwt-scrum-manager 自动导出 大学期间开发的项目。 它完全没用,充满了错误的东西,甚至可能不起作用。 保留在这里只是为了多愁善感的历史目的。 不要用它做任何事情。 原始描述 学术项目 ...
里面东西很多,都是关于GWT-COMET的内容,实现gwt的服务器推技术,包括gwt-comet-examples-1.2.3:google官网上的Test实例;gwt-comet-1.2.3.jar:jar包,gwt-example:聊天实例源代码(.java的),gwt-event-source...
part2:http://download.csdn.net/detail/u011029071/5986791 安装方法http://blog.csdn.net/u011029071/article/details/10143841
GWT浏览器插件离线安装包,针对IE的64位安装包,32位安装包转到http://download.csdn.net/detail/promingx/4236601
- 访问[CypalStudio](http://code.google.com/p/cypal-studio/)下载页面获取最新版本的CypalStudio。 - 下载完成后,将压缩包解压至Eclipse的目录下。 2. **配置GWTHome目录** - 打开Eclipse,进入`Window`—`...
从 code.google.com/p/gwt-comet 自动导出 概述 这个 gwt-comet 库为 GWT 提供了一个高效的 Comet 实现。 此库已移至 GitHub 该库通过在长期存在的 HTTP 请求上流式传输消息来实现 Comet,以最小化延迟和带宽要求...
从jar文件中扫描条目META-INF / versions / 9 / org / apache / logging / log4j / util / Base64Util.class时出错:/.../ eclipse-gwt-recipe / modules / gwt-web-eclipse / target / eclipse -gwt-recipe.web....