Eclipse PDE and log4j.properties?

I created an Eclipse PDE project and added log4j as a dependency using the slf4j-api and slf4j.log4j12 packages. In the class I created a registrar:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyTest {

  private static final Logger logger = LoggerFactory.getLogger(MyTest.class
      .getName());

  public void tt() {
    logger.info("log-test");

  }

}

but when I start the PDE project using the OSGI startup configuration, I get warnings:

log4j:WARN No appenders could be found for logger (loggin_test.MyTest).
log4j:WARN Please initialize the log4j system properly.

based on this information:

http://jaikiran.wordpress.com/2006/07/05/i-get-log4jwarn-no-appenders-could-be-found-for-logger-message-2/

I need to put log4j.properties in the path of the PDE class. I tried putting it in the root of the PDE project and adding:

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               log4j.properties

in the build.properties panel. But I still get the same warning. Where can I put the log4j.properties file in a PDE project?

EDIT: I also tried adding it to the / src folder, but that won't help.

+3
5

OSGi. , OSGi . , log4j, log4j, . log4j ( ).

2 :

  • Eclipse
  • log4j OSGi log4j

2 - , 1, .

+2

AFAIK, Log4j JAR, SLF4J - . JAR Apache -, , .

0

. , log4j.xml Project Build Path, ( ?). , (, eclipse ), , , log4j.xml, eclipse " ".

, " , ", :

  • "" > " "
  • - . , "Java Application".
  • "Classpath", "User Entries" "Advanced".
  • " " " ", "".
  • " " , log4j.xml, "" btn.
  • ""... ... !
0

, slf4j-simple slf4j-log4j12 ( log4j). , SteveD, . , ; .

, , , , . , , - :

Bundle bundle = bundleContext.getBundle();
URL entry = bundle.getEntry("log4j.properties");

try(InputStream inputStream = entry.openStream())
{
    PropertyConfigurator.configure(inputStream);
}
catch(IOException e) {}

, ; , /Eclipse, log4j.properties build.properties.

  • ( ", log4j " ), . , , (2) , (1) .
0

?

I recently added an entry to my Eclipse plugin. I used the logging tool that is built into the PDE. I will publish this just in case if this option were somehow missed. I did not understand that at first I did not need to add log4j, perhaps others also did not realize this.

0
source

Source: https://habr.com/ru/post/1761689/


All Articles