ServletContext.log消息在tomcat 7中的位置在哪里? [英] Where does the ServletContext.log messages go in tomcat 7?

查看:1166
本文介绍了ServletContext.log消息在tomcat 7中的位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java 7,tomcat 7.在学习servlet日志记录时,我写了一个简单的程序。

I am using Java 7, tomcat 7. While learning about servlet logging I wrote a simple program.

package net.codejava;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LogCheck
 */
@WebServlet("/LogCheck")
public class LogCheck extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#HttpServlet()
 */
public LogCheck() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub

    ServletContext context = getServletContext();
    String par = request.getParameter("msg");

    if (par == null || par.equals("")){
        context.log("No Message received",new IllegalStateException("Missing Parameter"));
    }else{
        context.log("Here is visitor's message:"+par);
    }

    PrintWriter out = response.getWriter();
    out.println("Log Testing.");

}

}

现在我是能够在Eclipse控制台中查看日志消息。但我在Tomcat Home / logs文件夹下看不到任何文件?
但我读到它应该将日志消息存储在一些日志文件中。在我的情况下,我没有看到任何日志文件。

Now I am able to see the log messages in my Eclipse console. But I do not see any files under Tomcat Home/logs folder ? But I read that it should store the log messages in some log files. I do not see any log file in my case.

我错过了一些配置吗?请帮助

Am I missing some configuraions? Please help

推荐答案

他们将被记录到localhost文件。$ {today} .log。

They will be logged to the file localhost.${today}.log.

正如Maks所说,ServletContext #log将使用类别 org.apache.catalina.core.ContainerBase。进行记录,当您查看Tomcat的日志记录时在 conf / logging.properties 中配置,你会看到这些消息转到前缀为 localhost的文件。

As Maks said, ServletContext#log will logged with the category org.apache.catalina.core.ContainerBase. and when you look at Tomcat's logging configuration in conf/logging.properties, you'll see that these messages go to files with the prefix localhost.

这篇关于ServletContext.log消息在tomcat 7中的位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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