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?
Of course not; all programs share the same monitor. (Or would share two
classes in all of my projects should write to the same log. Your analogy