Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

java - Grizzly Standalone Logging

i have setup a standalone grizzly/jersey server using maven and referencing the following dependencies

<dependency>
  <groupId>org.glassfish.grizzly</groupId>
  <artifactId>grizzly-http-server</artifactId>
  <version>2.3.10</version>
</dependency>
<dependency>
  <groupId>org.glassfish.jersey.containers</groupId>
  <artifactId>jersey-container-grizzly2-http</artifactId>
  <version>2.5.1</version>
</dependency>
<dependency>
  <groupId>org.glassfish.jersey.core</groupId>
  <artifactId>jersey-server</artifactId>
  <version>2.5.1</version>
</dependency>

I already implemented a client using the jersey client api to GET a resource, manipulate it and POST it back. Everything fine so far.

Now i wanted to POST something using curl which won't work. But now the question:

The thing is that i can't get Grizzly to log something to the console and haven't found any logfiles yet. Is grizzly using log4j or logging-api? Could anyone provide me with a logging.properties or something similar?

I'm starting the Server through a run config in eclipse specifiy

-Djava.util.logging.config.file=${project_loc}srcmain
esourceslogging.properties

as an argument. The references file exists and contains

.handlers= java.util.logging.ConsoleHandler
.level= ALL
java.util.logging.FileHandler.pattern = logs/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
org.glassfish.level = FINEST

This might be a very basic question but i'm sick of trial-and-error :-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've just had to solve the same problem. Here is my initialization code that convinces Grizzly HTTP server to display errors: http://source.apidesign.org/hg/bck2brwsr/rev/18ae4fbcfb87

Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
l.setLevel(Level.FINE);
l.setUseParentHandlers(false);
ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.ALL);
l.addHandler(ch);

I am using Grizzly 2.3.3


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...