Logging in a plugin?

I am writing a PacketInterceptor plugin for openfire (version > 3.0.0) to parse special data sent within a message. However, I would like to be able to send debug messages to a file, either a specific one or an openfire one (such as /var/log/openfire/debug.log). I am looking for a Logging mechanism within Openfire that would make this easy, so I don’t have to either use log4j or write my own logger just for my plugin.

I did notice Component’s Log object, but I haven’t looked too far into it.

Thanks,

Max

Hi Max,

You’ll want to use the Openfire Logger class.

Hope that helps,

Ryan

import org.jivesoftware.util.Log; // ... Log.error("Hello World");
Log.warn("Hello World");
Log.info("Hello World");
Log.debug("Hello World");

Thanks guys. I guess the email reply wasn’t working, I thought I was replying to the messages but I guess not. I missed those public static methods in the Log class, and after enabling debug in the openfire.xml file (true), I am getting messages in the debug.log using Log.debug();

By the way, this discussion system is awesome.

Thanks Ryan, I had been looking at this.

I was trying to find an instance of this class somewhere that I could use rather than having to create my own (which I tried).

I believe the component manager has something like this, but I am not registering a component (unless I should be?). Do you know where I can get an instance of this?

Thanks.

-max

By this I mean the Logger object.

Okay, I seem to have missed that org.jivesoftware.util.Log has public static debug and other methods. Not sure how I missed those, but I’ll try them and see if they work.

Thanks.

Hi Max,

Good to hear you figured it.

Good luck!

-Ryan

What is the 2020 recommendation for logging in a plugin? These are all deprecated.