PDA

View Full Version : [Solved] accessing getApi().getLogger from classes not extending anything



jproffer
07-18-2011, 05:39 PM
Is there a way to access the logger from a class not extending baseplugin or any of the managed API's?

tcarr
07-18-2011, 05:52 PM
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


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger logger = LoggerFactory.getLogger(NAME_OF_JAVA_CLASS_HERE.cl ass);


If you use the second, you will need to modify server/config/log4j.properties to set the logging level. See Logging (http://www.electrotank.com/docs/es5/manual/logging.htm).

jproffer
07-18-2011, 05:54 PM
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!

tcarr
07-18-2011, 05:56 PM
If you have questions about how to configure log4j.properties, you know where to find me. ;)

jproffer
07-18-2011, 06:01 PM
yeah it was easy to figure out, I got it working, thanks very much!