Solved Generating log file to plugin folder

Discussion in 'Plugin Development' started by P_S, Apr 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    Hi there,
    how can I generate log file to the plugin folder ? But I need all logs in one file and write logs on event. Like this:
    public void onPlayerJoin(final PlayerJoinEvent event) {
        writeLog("Player " + event.getPlayer().getName() + " is now on the server");
    public static void writeLog(String msg) {
    Thanks for any help :)
  2. Offline


    You could either use the plugin's logger retrieved via getLogger() and add a FileHandler to it, or you could simply write to a text file using a PrintWriter, Google should be helpful for more information.
    When determining the path of the logfile, you should use the plugin's getDataFolder() method.

    But in either way you shouldn't forget to create the plugin data folder if it doesn't exist (getDataFolder().makedir())
  3. Offline


    Ok thanks I got it ;)
Thread Status:
Not open for further replies.

Share This Page