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

    P_S

    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:
    Code:
    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

    upsj

    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

    P_S

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

Share This Page