First Plugin - Logger.getLogger() error

Discussion in 'Plugin Development' started by C1maCat, Jun 5, 2014.

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

    C1maCat

    Hey, I'm extremely new to java programming, (although I do have exeriance programming in python and C++) and I'm getting the error

    Code:
    The method getLogger(String) is undefined for the type Logger
    The information/tutorials I've been following is slightly old and may be outdated

    here is my code:

    Code:java
    1. package me.brennan.QuadPoint;
    2.  
    3. import org.apache.logging.log4j.Logger;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8.  
    9. public class QuadPoint extends JavaPlugin
    10. {
    11.  
    12.  
    13. public static final Logger logger = Logger.getLogger("Minecraft");
    14.  
    15.  
    16. public boolean en = false;
    17.  
    18. @Override
    19. public void onEnable()
    20. {
    21.  
    22. logger.info("[QuadPoint] has been enabled");
    23.  
    24.  
    25. }
    26. @Override
    27. public void onDisable()
    28. {
    29.  
    30.  
    31. }
    32. }
    33.  
     
  2. Offline

    L33m4n123

    It sure is outdated. There's a Javaplugin#getLogger
    and always crossreference too here. It has all you need to get started [IF you know how to Java]
     
  3. Offline

    ZodiacTheories

    C1maCat

    Instead of the Logger logger = logger.getLogger line - and the logger.info, just use getLogger().info("yourmessage");
     
  4. Code:java
    1.  
    2. @Override
    3. public void onEnable() {
    4. getLogger().info("[QuadPoint] has been enabled");
    5. }

    No need for all that extra public static final stuff.
     
  5. Offline

    RawCode

    protip: final keywork means NOTHING at runtime, only real feature of this keyword is enforced SET inside class constructor only usefull at very low level not available for bukkit plugins. xYourFreindx

    As for thread, i will teach you to resolve such issues SELF:
    [​IMG]

    If you set your workspace properly (not this case) or able to read raw signatures (again not this case) you can hover over method and press F3 in order to view source (or raw signature) of method.
     
    es359 likes this.
Thread Status:
Not open for further replies.

Share This Page