JAVA - 是否有用于客户端-服务器交互/连接的日志/任何文件?

发布于 2024-10-13 20:48:42 字数 158 浏览 3 评论 0原文

我有一个客户端-服务器应用程序,它与存储医生、患者等的数据库进行交互。该应用程序的目的是在医生办公室设置预约。

这是我的问题:是否有某种文件/日志/类可以显示客户端和服务器之间发送的所有内容。我需要尽可能多的信息,以便进行调试。

非常感谢。

克里斯蒂安.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淡淡の花香 2024-10-20 20:48:43

您的解决方案基于 NetBeans 吗?只是 Java 没有这个功能,除非您使用 java.util.Logger、Log4J、SLF4J 或其他日志框架。

您的患者管理器是开源的吗?我曾经开始研究基于 NetBeans 的解决方案(代号为 MedBeans,后来称为 Paracelsus),但在了解 Elexis 后放弃了这个想法,Elexis 是一种在中欧德语国家很流行的 Eclipse 方法。

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.

最佳男配角 2024-10-20 20:48:42

我猜你需要捕获客户端/服务器交互。在这种情况下,请查看 WireShark。它将显示客户端和服务器之间的所有网络流量,并解码 HTTP 和其他协议。请注意,它不依赖于 IDE 或语言。

然后,您可以将其与客户端和服务器端的日志文件结合使用,以全面了解正在发生的情况。

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.

漆黑的白昼 2024-10-20 20:48:42

您可以通过使用 DriverManager.setLogWriter() (如果我没记错的话,您需要在建立与数据库的任何连接之前执行此操作)

但是我不知道有哪个库会自动记录所有网络流量。为此,您需要像 Wireshark 这样的东西。

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.

柒夜笙歌凉 2024-10-20 20:48:42

如果这是 Web 应用程序注册过滤器,它将把来自客户端的所有请求记录到某个文件中。

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>

代码:

 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);
}

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文