Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Aspect questions? Date: Sun, 26 Feb 2012 21:49:21 -0800 Organization: albasani.net Lines: 104 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net FSl8LGNPFi3T0lEzRQUhhEQIg61ojujBkmK9e3N3sMqIs6JisG/GBof23+fqBPnAw6NcZ7e0Ksew2llVlggiIrawj6tBygITq+GkFQw5hVuF6ZKPYkwuhJFjysEY5Xye NNTP-Posting-Date: Mon, 27 Feb 2012 05:49:19 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="Q15YjA6gV1J8Otmyj/n7RdWJE76U5A4Sn+NsKTcdwGpvCwQPrOsSA9jBx23yaOh5HiXXIMThYnswVfgAmG0krSfHLBNDs5jJjyC2a922qwxN0WwKv9JaS1JBmRbXgE/C"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: Cancel-Lock: sha1:sIC2oihyW+rHi3G1njsfhNST7ts= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:12422 Novice wrote: > Assuming that project Foo has a single package, com.novice.foo and three > classes, hickory, dickory, and dock, class hickory's logger would be > "com.novice.foo.hickory", class dickory's logger would be > "com.novice.foo.dickory" and class dock's logger would be > "com.novice.foo.dock". > > Is that right now? Yes. Only do follow the naming conventions: com.novice.foo.Hickory com.novice.foo.Dickory com.novice.foo.Dock ... > ... Each class is going to be getting it's own logger with > > Logger logger Logger.getLogger(getClass().getName()); > ... > Yes, every class is already in one or another named package and has been > for a long time. I'm still struggling a bit over which classes belong in > the SAME package and which should not. As Patricia said, just make a decision and refactor later if you decide to. > My thinking is that classes in the Common PROJECT should also be in > packages that are distinct from the packages used for Projects Foo or > Bar, which will have names like "com.novice.foo" and "com.novice.bar". Usually. You have to think of the consequences and decide if they're the consequences you intend. > I'm using separate packages now so that > similar things are together. (That just feels like the right thing to do > but so far, most of my "feelings" have been wrong!) It's the right thing to do. Now find a rationale why - there is one, since it is the right thing to do. That way if pressed to explain your feeling you can. > Right. That is gradually sinking in, believe it or not! In fact, I'm just > about ready to replace all of the existing nonsense that I've been doing > with a > > Logger logger = Logger.getLogger(getClass().getName()); > > in all my classes. That's pretty much the idea I'm promoting, save for concerns of appropriate scope as discussed upthread. > So I want to end up with all of my classes in all of my Projects writing > to a single log? No. > Hmm. Yes, I suppose that makes sense. I need to review the whole > "inherit" aspect of logging but I've been thinking of one logger equating > to one log and that's not right, is it? See, the penny is dropping.... A logger is an object that writes to a log. There's no essential reason the ratio should be one to one. Au contraire, just like everything else in Java it's reasonable to expect multiple pointers to point to one thing and multiple writers to write to one output. Let me ask you this. In your favorite windowing OS, don't you have many programs each of them writing to a screen? Don't they all write to the same screen? You don't have a separate monitor for each program, do you? > Lots of loggers but only one log.... Yes, I need to get my head around > that and think of how that works. Maybe rereading that logging overview > will make that sink in.... Or thinking about many arrows hitting one target. ... > The only thing that REALLY bugs me still is that I can't find the darned > log records containing the weekdays that I mentioned elsewhere in the > thread. They're NOT at %h/java%u.log nor at the other place suggested in > the Tracing and Logging document. And THAT is really driving me crazy. I > can't think of anywhere else to look based on anything I've seen in the > references you and others have given me. I _think_ the logging.properties > file is ensuring that a physical log file is being written but maybe it's > messed up in some way to keep it from writing at all. Or from righting > INFO level records. But I don't think that's it. > > If you have any insight into that, you'd really be helping me out. It's > hard to absorb the information you are giving me when my mind keeps > obsessing on where the darned log files are. When I can't find a log file I'm searching for (it follows the rules for finding resources via a classloader, btw), I do a variant of $ find / -name foo.log 2> /dev/null Have you not tried searching your hard drive? -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg