更新时间:2022-12-13 12:00:04
这取决于您打算如何部署和运行此项目。对于分层多模块项目,我们通常在模块中包含一个log4j配置文件,其中包含 main
方法,该方法将启动该程序。
It depends on how you intend to deploy and run this project. For hierarchical multi-module projects, we generally included a log4j config file in the module with the main
method that would launch the program.
例如,考虑使用项目 client
和 server
的简化设置,它们都依赖于 framework
用于公共类(RMI接口,域对象等)。客户端作为桌面应用程序运行,具有自己的主
入口点,因此在src / main / resources下获取自己的log4j.properties文件。服务器模块也是如此。然而,框架不获取属性文件 - 其记录器调用将由其调用模块配置的任何记录器处理。
For example, consider a simplified setup with projects client
and server
which both rely on framework
for common classes (RMI interfaces, domain objects, etc). Client is run as a desktop application, has its own main
entry point, and thus gets its own log4j.properties file under src/main/resources. So does the server module. Framework, however, does not get a properties file -- its logger calls will be handled by whichever loggers have been configured by its calling module.