Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news.netfront.net!not-for-mail From: "a" Newsgroups: comp.lang.java.programmer Subject: Re: servletcontext listener vs servlet with high priority on loading Date: Thu, 11 Aug 2011 13:59:55 -0700 Organization: Netfront http://www.netfront.net/ Lines: 58 Message-ID: References: <1VO0q.42336$nj1.39176@newsfe19.iad> <35db14aa-dcbd-44ab-86eb-2b3695a58bf3@glegroupsg2000goo.googlegroups.com> NNTP-Posting-Host: 208.91.114.4 X-Trace: adenine.netfront.net 1313096396 61135 208.91.114.4 (11 Aug 2011 20:59:56 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Thu, 11 Aug 2011 20:59:56 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Original Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7031 "Lew" wrote in message news:35db14aa-dcbd-44ab-86eb-2b3695a58bf3@glegroupsg2000goo.googlegroups.com... markspace wrote: > a wrote: >> I build my own version of Log Util based on the log4j. The purpose is for >> convenience. It involves a lot of static method and static variable. > > I think you have just discovered that home built frameworks like this > are often not more convenient. Please try the existing configuration > files. +1 With log4j, the same-named logger (i.e., via the class or class name you pass to the constructor) is the same logger instance. It is better to name a logger by the class that uses it, as documented in the log4j instructions. This helps ops to maintain the program. I don't know whose convenience you're trying to serve, "a", but I will bet dollars to doughnuts it's not the folks whose convenience you ought to serve, namely the production personnel. Logging isn't for programmers, it's for ops. >> I expect objects can be instantiated in ServletContextListener, but not >> any >> static in a class. Is that true? Pls explain. > > I don't understand. I wonder if "a" means that you cannot instantiate a logger as a static variable, which of course is nonsense. You most definitely can, and sometimes should, instantiate a logger as a static variable. If "a" refers to objects in general, then it's even more nonsensical. It's Java. Of course you can instantiate objects as static members. Perhaps "a" ought to clarify his meaning. "a"? Also, "a", I heartily recommend you read *and study* the documentation for log4j (or any other framework that you use). -- Lew Hi Lew, Thank you very much. I will review the problem for my static logger. Can you please explain my first question? Besides, it is made for the job, why servlet context listener is better than using servlet with high load priority? Thanks --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---