English 中文(简体)
在日蚀工程结构中, 在动态网络应用程序中存储log4j. properities 文件的位置?
原标题:Where to store log4j.properties file in dynamic web application in eclipse project structure?

我把 log4j.properities 文件放在哪里?

PropertyConfigurator.configure("log4j.properties");  

我发现了以下链接:

< a href=" "https://stackoverflow.com/ questions/5081316/ where -is -the- 更正-place-to-put-log4j-properities-in-an-eclipse-Project" <哪里是将Log4j.propperities放入剪贴板工程的正确位置?

But as per the answer (selected) ,I think the setting is for the server itself and would be
applied to all projects.But I want this .properties file for my concerned project only.

我的项目结构是:

AccountCeation //project name  
    Java Resources: src  
        com.alw.controllers //packages  
        .....  
        log4j.properties  

我总是得到一个 < code> FileNotFoundException 。

NOTE: 我正在开发带有春季框架的动态网络应用程序。

请指引我在哪里我失踪?

问题回答

在阿帕奇岛的Tomcat 6, 运行一个Eclipse动态网络项目,

两个基本步骤

(1) 将log4j.properities文件输入战争文件的“类目录”。

(2) 从当前上下文中读取 log4j 属性文件, 我找到最好的方法就是从中访问当前线索的上下文和工作 。

对于以上第一步, 更改日圆构建进程, 添加一个附加目录, 最终会装入战争文件中 WEB- INF/ 类目录。 具体地说...

(1) 在 Eclipse 中,右键单击工程探索器中的您的工程,选择 New -gt; 文件夹 。 您可以指定文件夹名称, 但此情况下的标准是资源 。 新文件夹应该出现在您的工程的根层 。

(2) 将log4j. propertys文件移至此新文件夹。

(3) 再次右键单击工程, 并选择 Build- Path - & gt; 配置构建路径 。 选择源标签 。 单击 添加文件夹 按钮 。 浏览以查找您在以上步骤(1) 中创建的新文件夹 。 选择 OK 。

(4) 回到日食项目探索者的观点时,请注意,文件夹现已移到爪哇资源区(即由于日食表示抽象化,其根部不再是根部)。

(5) 清理你的项目。

(6) 验证战争文件中的 WEB- INF/ class 中是否存在. property 文件, 将战争文件导出到简单位置( 右键点击工程 - & gt; 导出 - & gt; 战争文件), 并检查文件内容。 请注意, log4j. property 文件现在出现在 WEB- INF/ class 中 。

现在对上方第二步, 访问上下文读取文件。 添加以下试图读取文件的代码 。 请注意, 此代码读出战争文件的上下文, 因此当战争文件从服务器移动到服务器时, 这应该有效 。

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
PropertyConfigurator.configure(classLoader.getResourceAsStream("log4j.properties") );




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签