On Fri, Jan 29, 2010 at 2:40 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk>wrote:
> Indrajit Raychaudhuri <indraj...@gmail.com> writes: > > > I am not sure you need to add yet another adapter on top of slf4j for > > MDC support. Enhancing the existing slf4j wrapper for the purpsoe > > might be worth an attempt instead. > > Yes but if we introduce a Lift MDC it would need to delegate to either > Log4j or Slf4j (which already has MDC wrapped for logback & log4j) > Looking at the way the Java frameworks do MDC, I'm not keen on it. I'd much rather see some kind of doWith mechanism: Log.doWith("name" -> "value", "otherName" -> "otherValue") { .... } That way, you can clearly delineate the custom log information. It might also be interesting to see log levels changed in the same way. I'd like to apply Scala and Lift constructs to Logging rather than just borrow existing paradigms. In terms of slf4j, I have a generic allergic reaction to it. There was a thread 2 years ago on Slf4j that seemed to me to be a bunch of zealots demanding it as the default without giving any reasons other than "it's better" (think emacs vs vi.) If there are real reasons to insert it into the mix, I'll listen to them, but I'd rather start at a design that's Scala and Lift-like and move down the implementation stack to see why it's a win to insert slf4j. Thanks, David > > > That said, I think there is room (and opportunity) for defaulting to > > lightweight wrapper over slf4j and letting users choose any underlying > > framework (simple, log4j, logback, jul) at build/deploy time. I am > > optimistic this would be doable without any code change on existing > > Lift applications. And keep OSGi happiness in the way. > > That was my proposal > > > As such, I thing we should be careful and avoid duplicating (very > > similar impl of) MDC enhancement to both Log4JLogger and Slf4JLogger. > > I agree and this was what caused me to write the email in the first > place :-) > > > I would be inclined to consider: > > > > - Zero code change in application for switching log implementations > > (nothing should be necessary to be put in Boot.scala) > > As long as you don't want to tweak the backend config. I think you still > need to configure the underlying logging framework in order to support > reading (dev|prod|test) config files. > > > - Tuck in everything behind the helper object(s) - Log for the root > > logger or other objects introduced because of the Loggable trait > > > > - Have MDC and other enhancements aligned to slf4j. Per design > > slf4j-api expects a real logging framework behind it (bundled or > > otherwise). > > > > - In Lift, for guaranteed compatibility, default to log4j (by using > > log4j wrapper of slf4j) - but still allow using logback, jul etc. just > > by flipping the dependency during build. Bonus, slf4j would fallback > > to simple logger if none of the dependencies are available. > > > > - Existing applications can just add log4j bridge for the existing > behavior. > > > > - New applications (generated from archetype) mark slf4j-api as > > compile scope dependency and have one of the implementations > > (simple,log4j,logback etc.) added as either compile scope or provided > > scope (to cover for log4j in container classpath). This can even be > > offered as choice during archetype:generate! > > > > Thoughts? > > That was pretty much what I had in mind, but probably didn't articulate > too well :-) I'll wait for David to chime in since he had objections. > > In the meantime, I've pushed the changes (keeping the Log4j logger) to > http://github.com/dpp/liftweb/tree/jnm_issue_309 > > I've updated the hellolift example to use Slf4j over logback. > > /Jeppe > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.