users@glassfish.java.net

thread name in log messages?

From: Bobby Bissett <bbissett_at_gmail.com>
Date: Wed, 5 Sep 2012 11:27:22 -0400

Hi all,

Just curious: where does the thread name come from in messages logged
from an EE app? For instance, in GF 3.1.2.2, I have this servlet:

--- begin ---
public class TestServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

        resp.getWriter().println("hi there");

        TestThread t = new TestThread();
        t.start();
    }

    static class TestThread extends Thread {

        TestThread() {
            super("bobby_test_thread");
        }

        @Override
        public void run() {
            Logger.getLogger("testLogger").info("Hi, I am " + getName());
        }
    }
}
--- end ---

...and when accessed the log contains:

[#|2012-09-05T09:45:35.156-0400|INFO|glassfish3.1.2|testLogger|_ThreadID=24;_ThreadName=Thread-4;|Hi,
I am bobby_test_thread|#]

From where does that "Thread-4" name come (and is there any way to
have it list the thread that logged the message)?

Thanks,
Bobby