Hello (Joakim)!
I'm unsucessfully trying to have one log file per deployed context. Found
SO quesion http://stackoverflow.com/questions/11902550/jetty-log-per-context
that
directs to Jetty wiki
http://wiki.eclipse.org/Jetty/Tutorial/Sifting_Logs_with_Logback.
I followed the tutorial from wiki but I want one log file per context, not
per host as described in that page. So I added line
MDC.put("context",request.getContextPath());
to MDCHandler (
https://github.com/jetty-project/jetty-and-logback-example/blob/master/jetty-slf4j-mdc-handler/src/main/java/org/eclipse/jetty/examples/logging/MDCHandler.java).
It looks now like this:
public class MDCHandler extends HandlerWrapper
{
@Override
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
{
try
{
MDC.put("host",request.getServerName());
* *MDC.put("context",request.getContextPath());*
*
super.handle(target,baseRequest,request,response);
}
finally
{
MDC.clear();
}
}
}
But MDC "context" is always null. According to
http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html#getContextPath()
it
cannot be null. Even for root contexts (/) method should return empty
string (""). Therefore I can't use it for Logback sifting.
Is there anybody who achived "one log file per context" solution? Can you
share your know-how?
Thanks!
--
Hezky den / Have a nice day
Libor JELÍNEK
VIRTAGE SOFTWARE // software - design - web
Lucni 542 // 285 04 Uhlirske Janovice // Czech Republic
support: +420 315 555 488 // cell: +420 777 205 142
email/jabber: [email protected] // web: www.virtage.com
Visit our developer adventures at http://devblog.virtage.com!
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users