Specify the location of the log4j.properties in the JAVA project, not the __java that must be placed under SRC

Source: Internet
Author: User
Tags log4j

If you're just building a Java project and you don't want to put it in the SRC directory, you can use the following method to specify the location of the log4j.properties.

	private void Initlog4jconfig () {
		Properties props = null;
		FileInputStream FIS = null;
		try {
			//Read configuration information from the configuration file dbinfo.properties
			props = new Properties ();
			FIS = new FileInputStream ("Config/log4j.properties");
			Props.load (FIS);
			Propertyconfigurator.configure (props),//Mount log4j configuration information
		} catch (Exception e) {
			e.printstacktrace ();
		} Finally {
			if (FIS!= null)
				try {
					fis.close ();
				} catch (IOException e) {
					e.printstacktrace (); c17/>}
			fis = null;

The point is:

Propertyconfigurator.configure (props);
This sentence.

If you do not specify the following prompts:


Log4j:warn No Appenders could is found for logger (org.apache.activemq.thread.TaskRunnerFactory).
Log4j:warn Please initialize the log4j system properly.
Log4j:warn the Http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

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.