Programmatically retrieve folder locations

Hi all,
I'm developing a plugin and I'd like to log some actions using log4j.
I have to decide where to put the log file generated by log4j.
Which is the safest location, in order not to throw "Access denied" or similar Exceptions?
Is there a way to retrieve such locations in a programmatic way?

Thank you very much


Comment actions Permalink

The best way is to use standard IntelliJ logging mechanism:

import com.intellij.openapi.diagnostic.Logger;
private static final Logger LOG = Logger.getInstance(YourClass.class.getName());;

By default INFO level and above is saved to file, you may tune log.xml file in IntelliJ IDEA installation. Logs appear in standard log file (Help | Show logs).

Comment actions Permalink

Thank you Alexander,
the retrieval of safe location is not only needed for logging purpose, but also for other tasks.
So, apart from logging purpose, in which location may a write my own files?

Comment actions Permalink

Is your question related to the IDE?
System temp folder seems to be the best: See also other methods of FileUtil class.

Comment actions Permalink

Thank you very much Alexander, that's exactly what I need!


Please sign in to leave a comment.