独立Java项目的log4j [英] log4j for standalone java project

查看:44
本文介绍了独立Java项目的log4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在考虑将log4j用于我的独立Java项目.是否可以将其用于Java项目(而非Web应用程序).

I was thinking to use log4j for my standalone java project. Is it possible to use it for java project(not a web app).

如果可能的话,我应该如何初始化属性文件以及在哪里?我放了属性文件(目录结构).

If its possible then how should I be able to initialize the properties file and where should I put the properties file(directory structure).

感谢您的帮助.

推荐答案

是的,有可能,我们一直在这样做.您只需在类路径上需要一个log4j.properties文件,在大多数情况下,这意味着在jar文件的基本目录中.如果您希望有多个具有不同配置的属性文件,您可以在第一个日志记录语句之前的某个入口点中创建一个属性配置器.

Yes, it is possible, we do it all the time. You just need a log4j.properties file on your classpath, which in most cases means in the base directory of your jar file. If you wish to have multiple properties files with differing configurations, you can create a properties configurator in some entry point before your first logging statement.

这篇关于独立Java项目的log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆