我的工作与Netbeans的EJB模块我的Java企业应用程序。
当我运行“MyClass.java”我只能查看错误级别。
MyEnterpriseApplication的EJB:源代码包:
package com.mycompany;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MyClass {
public static final Logger logger = LogManager.getLogger(MyClass.class);
public static void main(String[] arg) {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:context.xml");
logger.info("level info");
logger.error("level error");
logger.debug("level debug");
logger.warn("level warn");
}
}
当我运行这个类...
输出:
------------------------------------------------------------------------
Building MyEnterpriseApplication-ejb 1.0-SNAPSHOT
------------------------------------------------------------------------
[dependency:copy]
[resources:resources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
[compiler:compile]
Compiling 1 source file to Z:\NetBeansProjects\MyEnterpriseApplication\MyEnterpriseApplication-ejb\target\classes
[exec:exec]
20:26:23.885 [main] ERROR com.mycompany.MyClass - level error
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 2.328s
Finished at: Mon May 27 20:26:23 CEST 2013
Final Memory: 14M/162M
------------------------------------------------------------------------
我如何添加的log4j.xml文件,并添加到Spring上下文文件? 这是方法?