+ Reply to Thread
Results 1 to 5 of 5

Thread: accessing getApi().getLogger from classes not extending anything

  1. #1
    Member
    Join Date
    May 2011
    Posts
    35
    Thanks
    7
    Thanked 0 Times in 0 Posts

    accessing getApi().getLogger from classes not extending anything

    Is there a way to access the logger from a class not extending baseplugin or any of the managed API's?
    Last edited by tcarr; 07-18-2011 at 06:02 PM. Reason: question was answered

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    The simplest way is to have the plugin pass a Logger variable (getApi().getLogger()) or an ElectroServerApi variable (getApi()).

    The usual practice is to use
    Code:
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
        private static final Logger logger = LoggerFactory.getLogger(NAME_OF_JAVA_CLASS_HERE.class);
    If you use the second, you will need to modify server/config/log4j.properties to set the logging level. See Logging.
    Last edited by tcarr; 07-18-2011 at 05:55 PM.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. The Following User Says Thank You to tcarr For This Useful Post:

    jproffer (07-18-2011)

  4. #3
    Member
    Join Date
    May 2011
    Posts
    35
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Ahh. I had the second method implemented but it was not showing anything, so was wondering what I missed. Looks like it was the log4j.properties Thanks!

  5. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    If you have questions about how to configure log4j.properties, you know where to find me.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  6. #5
    Member
    Join Date
    May 2011
    Posts
    35
    Thanks
    7
    Thanked 0 Times in 0 Posts
    yeah it was easy to figure out, I got it working, thanks very much!

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts