Can't make IntelliJ see my file

I'm running a little console app from IntelliJ using the Run->Run menu.  I have a file in a folder called resouces.  I can't get IntelliJ to see this file.  When I run my app, I do not get the logging in the console window I expect.   When I remove my file, I do not get the typical "you must configure log4j properly" warning.  All signs point to another file being in the classpath.  But there isn't one.  I've tried putting my properties file in the src directory, making resources a source directory from project properties, making the resources folder a library module, and specifying the file using -D on the VM line.

I'm new to 9.* and am using the 'community version' of IntelliJ here at home.

I'm using a Mac.

I'm out of ideas.  Any suggestions?


When I read a log4j file from the class path I just add the directory that contains the file to the classpath via a Module Library (although your post says you have already tried that).

At the risk of stating the obvious, I assume you are trying to read in the file like this?



No, I have never had to explicity read a file before.

This is how I create the logger:

private final static Logger log = Logger.getLogger(ExTest.class.getName());

Logger is likely reading the file.


Also, try taking log4j out of the equation and see if you can load the property file yourself:

       Properties props = new Properties();         try {             final InputStream inStream = YourClass.class.getClassLoader().getResourceAsStream("");             if (inStream != null) {                 props.load(inStream);             } else {                 System.out.println("not on classpath");             }         } catch (IOException e) {             logger.error("Exception ", e);         }         for (Map.Entry<Object, Object> entry : props.entrySet()) {             System.out.println(entry);         }


That code displays my file as we'd expect it to.  Perhaps my properties file is hosed and Log4J is using a default configuration.

How did you format the code to make it look like that?


I usually explicitly read in the file so there are no surprises.

You can try the code snippet to at least see if it your is on the classpath.

Also, make sure you haven't set the system property "log4j.defaultInitOverride" to something other than false (that will cause log4j's default configuration procedure to be skipped)


Click on the double arrows and you will see this:

Screen shot 2010-09-22 at 9.50.01 AM.png


Ok, I am a moron indeed.  I had imported the stock Logger, not log4j.  They are similar enough that the code compiles but obviously the stock logger doesn't read the file.

Sorry to waste your time.


When something seems insane, check your assumptions.


Don't worry, you aren't the first one that has happened to:) (I was going to mention to make sure you hadn't accidentally imported java.util.Logger but then forgot to)

Usually it happens if you use Logger before you have added log4j to the project's classpath.

If you are using Intellij9 it has a very nice feature to prevent this. Under Settings->Editor->Auto Import there is a Exclude from Import and Completion option where you can tell it to ignore java.util.loggin  (believe this was introduced in 9.x). My settings:

Screen shot 2010-09-22 at 10.02.40 AM.png


Basically you can say, "This package is so disruptive that I never want to add it to my project" :^O


Please sign in to leave a comment.