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

Best
cghersi

4 comments
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());
LOG.xxx(...);

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).

0
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?

0
Comment actions Permalink

Is your question related to the IDE?
System temp folder seems to be the best: com.intellij.openapi.util.io.FileUtil.getTempDirectory(). See also other methods of FileUtil class.

0
Comment actions Permalink

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

0

Please sign in to leave a comment.