Solved How to log to console?

Discussion in 'Plugin Development' started by Nonam82, Aug 7, 2016.

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

    Nonam82

    Sorry this is very basic but I am just getting back into making a plugin after years of not doing so.. How do I log things to the console from my listener class? Here is my code with a comment showing where I want to log. How do I make it so that I can use getLogger().info()? It just gives me an error- "The method getLogger() is undefined for the type EntityListener".

    Code:
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    
    
    public class EntityListener implements Listener {
    
    
    
        public EntityListener(FacAnimals plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
    
        @EventHandler
        public void onDamage(EntityDamageByEntityEvent event){
            // WANT TO LOG TO CONSOLE HERE
            event.setCancelled(true);
        
        }
    
    }
    
    
     
  2. Offline

    SuperSniper

    getLogger().info("your message");

    There's also getLogger().
    • SEVERE (highest value)
    • WARNING
    • INFO
    • CONFIG
    • FINE
    • FINER
    • FINEST (lowest value)
    EDIT: Since your class is NOT extending JavaPlugin, use Bukkit.getLogger()
     
    EpicEfeathers and jhplayer like this.
  3. Offline

    Nonam82

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page