如何从servlet输出文本到java控制台 [英] how to ouput text to java console from servlet

查看:203
本文介绍了如何从servlet输出文本到java控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个servlet。但它不能按预期工作。因此为了调试的目的,我想打印语句到java控制台(可以使用任务栏中的java图标打开的那个)。但是,如果我使用System.out.println(message),它不会显示在java控制台。

I have a servlet. But it is not working as desired. Hence for debugging purposes, I want to print statements to the java console(the one that can be opened using the java icon in taskbar). However, if I use System.out.println("message"), it doesnt display in java console.

有没有其他方式,我可以显示消息到控制台从servlet?

Is there any alternative way where I can display messages to the console from the servlet? Or can anyone suggest me an alternative way to display messages to any other console?

推荐答案

在哪个控制台中,您可以使用其他控制台期望它出现?

In which console do you expect it to appear?

根据servlet容器(我假设为Tomcat),日志存储在 logs 文件夹中。对于Tomcat,这是 tomcat / logs (或更多地称为 CATALINA_HOME / logs )。

Depending on the servlet container (I assume Tomcat), the logs are stored in a logs folder. For Tomcat this is tomcat/logs (or more often referred to as CATALINA_HOME/logs). If you are running it from within an IDE - they should be in the IDE console.

使用 System.out 不适用于实际产品 - 使用日志框架(如 log4j )。

As a sidenote, using System.out isn't advisable for a real product - use a logging framework (like log4j).

这篇关于如何从servlet输出文本到java控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆