10

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}\src\main\resources\logging.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 :-)

thuri
  • 302
  • 1
  • 2
  • 10

3 Answers3

14

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

Jaroslav Tulach
  • 519
  • 4
  • 7
3

Grizzly uses JDK logging API. Not sure why it doesn't work for you, double check that java.util.logging.config.file property is getting properly resolved.

alexey
  • 1,959
  • 10
  • 9
  • Do you mean i should check whether the ${project_loc} variable is resolved or how can i accomplish that "double checking"? – thuri Jan 27 '14 at 12:47
  • 1
    try to log something in your project using JDK Logger and see if it works. – alexey Jan 27 '14 at 16:58
  • So logging works. Seems like grizzly isn't talking much. So i'll try to work with the jersey logging https://jersey.java.net/documentation/latest/user-guide.html#tracing. But thanks so far. – thuri Jan 28 '14 at 13:21
0

Check if you can log something with level FINE in your application.

Logger LOG = Logger.getLogger(MyResource.class.getName());
LOG.log(Level.FINE, "a message")

Jersey is using JDK logging and to see its debug output (e.g. in the grizzly console) you have to get the logging configuration right. This configuration file worked for me:

handlers=java.util.logging.ConsoleHandler
.level=FINE
java.util.logging.ConsoleHandler.level=ALL
rschmidt13
  • 349
  • 3
  • 3