Application log level

155 views
Skip to first unread message

Andreas

unread,
Apr 7, 2010, 9:24:10 AM4/7/10
to minlog-users
Hi

I have a suggestion that would be great if someone implemented. I
think it would be great with another log level for application level
informational messages. I have a server for an application i'm
building and I want to print informational messages to the servers log
when a client connects for example so that the end user can see what's
going on instead of just a black terminal.

For now I've solved this by creating a subclass of Log.Logger and I
store an instance of it in my own application but it's kinda ugly.

Thanks for a great simplistic logging library by the way!

Regards,
Andreas Falk

Nate

unread,
Apr 7, 2010, 5:25:25 PM4/7/10
to minlog...@googlegroups.com
Hi Andreas,

You can use the INFO and other logging level for your application. Any 3rd party libraries you may be using (eg, KryoNet) should do all their logging with a specific category string, eg:

if (INFO) info("kryonet", "Some KryoNet message...");

You can use this category string to differentiate 3rd party messages from your application's messages. I usually don't pass a category string for my application to cut down on typing, eg:

if (INFO) info("My application's message...");

Subclassing Logger is the right way to filter messages. Eg, this code will only log messages that don't have a category:

Log.setLogger(new Log.Logger() {
    public void log (int level, String category, String message, Throwable ex) {
        if (category != null) return;
        super.log(level, category, message, ex);
    }
});

-Nate



--
You received this message because you are subscribed to the "minlog-users" group.
http://groups.google.com/group/minlog-users

To unsubscribe, reply using "remove me" as the subject.

Andreas

unread,
Apr 9, 2010, 11:52:36 AM4/9/10
to minlog-users
Subclassing in the way you show to filter messages is probably a lot
better solution than the way I was subclassing it. Thanks for the
help!

Andreas

Reply all
Reply to author
Forward
0 new messages