开发者

JAVA - Is there a log/whatever file for client-server interactions/connections?

I have a client-server application that interacts with a database that stores doctors, patients etc. The purpose of this application is to set开发者_如何转开发 up appointment at a doctor's office.

Here's my question: Is there some kind of file/log/class that shows absolutely everything that get sent between the client and the server. I need as much info as possible so I can debug.

Thank you very much.

Cristian.


I'm guessing you need to capture client/server interactions. In that case check out WireShark. It'll display all the network traffic between the client and server, and decode HTTP and other protocols. Note that it's not IDE or language-dependent.

You can then use this coupled with your logfiles on the client and server side to get a complete picture of what's going on.


You can log the JDBC communication by providing a logfile for the JDBC driver using DriverManager.setLogWriter() (you need to do this before establishing any connection to the database if I'm not mistaken)

But I don't know of any library that will automatically log all network traffic. For that you'll need something like Wireshark.


If this is web application register filter that will log all request from client into some file.

web.xml:

<filter>
    <filter-name>MyLogFilter</filter-name>
    <filter-class>my.package.MyLogFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>MyLogFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

code:

 public class MyLogFilter implements Filter {
  private static final Logger log = Logger.getLogger(MyLogFilter.class);
   public void doFilter(ServletRequest req, ServletResponse res,
          FilterChain chain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;

    //Get the IP address of client machine.
    String ipAddress = request.getRemoteAddr();

    //Log the IP address and current timestamp.
    log.info("IP "+ipAddress + ", Time "
                        + new Date().toString());

    chain.doFilter(req, res);
}


Is your solution based on NetBeans? Just Java doesn't have that, unless you make use of java.util.Logger, Log4J, SLF4J or other logging frameworks.

Is your patient manager Open Source? I once started working on NetBeans based solution (code named MedBeans, later Paracelsus) but abandoned the idea after I learned about Elexis, an Eclipse approach popular especially in German speaking countries of Central Europe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜