Tomcat logs, log4j logs in project, console-where did my logs end up?

Source: Internet
Author: User

1. Tomcat comes with a log feature that instantly has log4j in your project and does not affect Tomcat logging itself.

2 . The log in log4j in your project specifies where to print (console or file), where it will be printed, regardless of the Tomat log.

--If the log4j in your project is specified to print to the console, and your Tomcat is on the console, you can observe the log at the console.

-If you use log4j to process tomcat logs (specifically, you need to configure the Tomcat configuration file yourself), then Tomcat will use log4j to print, but this is still not the same log4j as the log4j in your project.

3, about the abnormal log printing

If you have handled an exception in your project:

        try  {            int i = 1/0;        } Catch (Exception e) {            e.printstacktrace ();        }

  A, then this exception message will print to your console. You said you didn't open the console, did you run it in the form of a service? Then you can't see the abnormal information.

  B, you throw in your project directly, and there is no place to deal with this exception, then the last exception will be thrown to your container--tomcat,tomcat This exception is logged in the. log file for localhost.

  C, you are using the log4j:

Logfactory.getlog (Logger.  Class). Error ("Thread:" +i+ "-print:" +j+ "-currentthread:" +thread.currentthread () ");

Then you should look in your log4j configuration file and see what it says to print the error message.

-If you are printing to the console, go to the console to find it. If there is no console, then this error message is lost.

-If you write to a file, it is in your file, of course.

4. Control Station

Tomcat also outputs logs to the console by default, which is recorded in the Catalina. Date. log file that is consistent.

Syso, E.printstacktrace () in the program, and log4j If you configure the output log to the console, they will all appear on the console,

Although you have so many logs on the console in eclipse, you need to understand that they are not written by the same logger.

Tomcat logs, log4j logs in project, console-where did my logs end up?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.