tag:blogger.com,1999:blog-8875558920754897232.post3592551889543918228..comments2022-10-25T06:09:25.930-07:00Comments on Programmatically Speaking: DSL: Domain Specific LoggingTorgnyhttp://www.blogger.com/profile/12146418455302215748noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8875558920754897232.post-71486034164765763722010-08-24T03:36:49.052-07:002010-08-24T03:36:49.052-07:00Thanks for the link. No, the log string was not bu...Thanks for the link. No, the log string was not built if it wasn't used. Sorry that I didn't make it clear in the post.<br /><br />All that happened was that references to the parts of the log string were collected. These parts were then "stringified" with "toString()" (if the part wasn't a string already) and then concatinated if and only if the log entry will be printed to the log. It not, the references was simply discarded.Torgnyhttps://www.blogger.com/profile/12146418455302215748noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-16562573928959194652010-08-24T00:40:41.276-07:002010-08-24T00:40:41.276-07:00So the impl you had was building that log string a...So the impl you had was building that log string all the time, then passing it to the log framework which depending on the level used it or not? <br /><br />http://www.slf4j.org/faq.html#logging_performanceMagnus Heinohttps://www.blogger.com/profile/04349955384507774969noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-64986598412305264062010-07-20T01:42:53.202-07:002010-07-20T01:42:53.202-07:00Yes, I mean something like EntryBuilder in your ex...Yes, I mean something like EntryBuilder in your example.<br /><br />I agree that it is not nice looking/readable code. :)Игорь Потеряевhttps://www.blogger.com/profile/10344754190722462921noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-27974078492069207382010-07-20T01:15:55.130-07:002010-07-20T01:15:55.130-07:00Not entirely sure I understand. Do you mean someth...Not entirely sure I understand. Do you mean something like:<br /><br />logger.info(new EntryBuilder().tryingTo("open port").variable("address", address).done());<br /><br />That would be possible of course, but it's not particularly nice to look at/read. It's a bit messy in my opinion. But it sure works! :) <br /><br />Or do I misunderstand you?Torgnyhttps://www.blogger.com/profile/12146418455302215748noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-22823088485288962712010-07-20T00:59:39.085-07:002010-07-20T00:59:39.085-07:00Hi, Torgny.
If I understand correctly, your imple...Hi, Torgny.<br /><br />If I understand correctly, your implementation uses something like ThreadLocal for home-written logger.<br /><br />It's ok, but maybe it will be simple to use some kind of LogEntry object with fluent API and pass it to ordinary (jul, log4j, logback) logger.<br /><br />Just thinking.Игорь Потеряевhttps://www.blogger.com/profile/10344754190722462921noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-85017240179735096842010-07-19T12:34:56.137-07:002010-07-19T12:34:56.137-07:00Thanks for you comment!
I'm sorry I can't ...Thanks for you comment!<br />I'm sorry I can't publish the source since it was written at the company where I worked. But I can tell you roughly how the problem with thread-safety was solved.<br /><br />It was quite simple actually, because every thread had its own instance of your home-written logger. Those instances built the string to log using a fluent interface, and when the entire string was built the string was passed to java.util.logging.<br /><br />Not sure if that makes sense... I hope it does. :)Torgnyhttps://www.blogger.com/profile/12146418455302215748noreply@blogger.comtag:blogger.com,1999:blog-8875558920754897232.post-10193598701291397932010-07-19T10:41:00.094-07:002010-07-19T10:41:00.094-07:00First of all, hanks for this blog post.
Fluent AP...First of all, hanks for this blog post.<br /><br />Fluent API is good, but in multi-threading environment fluent logging implementation should be thead-safe, and it is the main problem for implementation. Current API og java.util.logging, log4j, slf4j, etc. make logging not fluently, but thread-safe. <br />It is nice, if your implementation solve this. Can it be published under liberael license ?Игорь Потеряевhttps://www.blogger.com/profile/10344754190722462921noreply@blogger.com