user1439247
user1439247

Reputation: 21

logging and/or debugging on remote Glassfish

I have a problem. I deployed a web service on a remote Glassfish instance. Now I need to have some simple log or debug system in order to correct my code( using simple prints would be preferable). My idea was to use the glassfish log file as I can access it from admin GUI, but it doesn't work; I'm not able to write into this file. Any idea to solve this problem? Or any other method that I can use? Thanks

Upvotes: 2

Views: 7803

Answers (1)

flup
flup

Reputation: 27104

Glassfish's default logging solution is to use the java.util.logging (JUL) logger.

You can use it in your code as follows:

package org.example.something;

[...]

import java.util.logging.Logger;

[...]

Logger logger = Logger.getLogger(getClass().getName());
logger.severe("severe");
logger.info("info");
logger.fine("fine");

You can administrate glassfish logging through the administration console which runs on http://servername:4848/. There are other ways too.

In Glassfish 3.1, which is the one I tried, you can set the log level for each logger on the Configurations, your-server-config, Logger Settings page, Log Levels tab. You can press Add Logger. You give the package of your class as a Logger Name, so in this example org.example.something and select the log level. Anything on or above this level will get logged, as long as the log level for com.sun.enterprise.server.logging.GFFileHandler is also set on or below this level. See Glassfish 3.1.1 suddenly stopped writing to server log

Press save and the changes should take effect immediately. In the General tab, you find the configuration of where the logging will end up.

You can browse the logging in the administration tool too. Select Server, the General tab, View Log Files.

Upvotes: 5

Related Questions