R
Rhino
I'm trying to figure out the best way to set up logging for my
development shop. In a nutshell, I'd like the advice of experienced
developers/designers to figure out how many logs I should have and where
I should set each one up. To clarify what I mean, please allow me to
sketch a hypothetical situation which would illustrate my concerns.
Let's say that my company is called Foo Inc. My Java development is done
using Eclipse. Various projects are on the go, including Baz and Fuzz.
There is also a body of existing code that does various useful things,
like general utilities.
The Baz project has its own package, com.foo.baz, and includes all the
classes used exclusively by Baz, including:
- Supremo (the main class that invokes the other Baz classes)
- Alpha
- Beta
- Gamma
There is also a com.foo.baz.Resources package within the Baz project
containing resource bundles used by Baz.
The Fuzz project has its own package, com.foo.fuzz, and includes all the
classes used by Fuzz, including:
- Boss (the main class that invokes the other Fuzz classes)
- Grunt1
- Grunt2
- Grunt3
There is also a com.foo.fuzz.Resources package within the Fuzz project
containing resource bundles used by Fuzz.
The more general code is in its own project, Common, and is organized
into various specialized packages, including:
- com.foo.common (miscellaneous common code)
- com.foo.common.Resources (resource bundles for com.foo.common)
- com.foo.common.error (common code used for error handling)
- com.foo.common.error.Resources (resource bundles for
com.foo.common.error)
- com.foo.common.utilities (commonly used utilties of one kind or
another)
- com.foo.common.utilities.Resources (resource bundles for
com.foo.common.utilities)
Okay, now that I've set the scene, let me ask some specific questions
that will help me figure out the best ways to organize my logging.
1. Should I make use of levels of Loggers here? For example, should I
have a master Logger that contains all important messages written to any
package whose name starts with com.foo, i.e. any message written by any
of my classes that is of appropriate severity? And then have separate
project-level Logger for com.foo.baz and com.foo.fuzz? Or should I not
bother with the "master" log and just create separate logs for
com.foo.baz and com.foo.fuzz? I can see some advantages to having a
master log: it could contain only records indicating relatively severe
situations so that management could exercise oversight (and verify that a
given problem was being addressed) while all messages, serious and minor,
could be written to the project-level log for detailed monitoring by
developers.
2. Should there be a separate log for log records written by common code,
i.e. everything that has a package name starting with com.foo.common? Or
should log records generated by the common classes be written to the logs
of common.foo.baz or common.foo.fuzz, depending on which project invoked
the common code? For example, let's say that com.foo.Fuzz.Grunt1
instantiation com.foo.common.utilities.StringUtils and StringUtils wants
to log something. Should StringUtils write to a log that is associated
with com.foo.Fuzz or one that is associated with com.foo.common?
I think I'll have some followup questions once I've heard the answers to
these so I'll hold off for now.
development shop. In a nutshell, I'd like the advice of experienced
developers/designers to figure out how many logs I should have and where
I should set each one up. To clarify what I mean, please allow me to
sketch a hypothetical situation which would illustrate my concerns.
Let's say that my company is called Foo Inc. My Java development is done
using Eclipse. Various projects are on the go, including Baz and Fuzz.
There is also a body of existing code that does various useful things,
like general utilities.
The Baz project has its own package, com.foo.baz, and includes all the
classes used exclusively by Baz, including:
- Supremo (the main class that invokes the other Baz classes)
- Alpha
- Beta
- Gamma
There is also a com.foo.baz.Resources package within the Baz project
containing resource bundles used by Baz.
The Fuzz project has its own package, com.foo.fuzz, and includes all the
classes used by Fuzz, including:
- Boss (the main class that invokes the other Fuzz classes)
- Grunt1
- Grunt2
- Grunt3
There is also a com.foo.fuzz.Resources package within the Fuzz project
containing resource bundles used by Fuzz.
The more general code is in its own project, Common, and is organized
into various specialized packages, including:
- com.foo.common (miscellaneous common code)
- com.foo.common.Resources (resource bundles for com.foo.common)
- com.foo.common.error (common code used for error handling)
- com.foo.common.error.Resources (resource bundles for
com.foo.common.error)
- com.foo.common.utilities (commonly used utilties of one kind or
another)
- com.foo.common.utilities.Resources (resource bundles for
com.foo.common.utilities)
Okay, now that I've set the scene, let me ask some specific questions
that will help me figure out the best ways to organize my logging.
1. Should I make use of levels of Loggers here? For example, should I
have a master Logger that contains all important messages written to any
package whose name starts with com.foo, i.e. any message written by any
of my classes that is of appropriate severity? And then have separate
project-level Logger for com.foo.baz and com.foo.fuzz? Or should I not
bother with the "master" log and just create separate logs for
com.foo.baz and com.foo.fuzz? I can see some advantages to having a
master log: it could contain only records indicating relatively severe
situations so that management could exercise oversight (and verify that a
given problem was being addressed) while all messages, serious and minor,
could be written to the project-level log for detailed monitoring by
developers.
2. Should there be a separate log for log records written by common code,
i.e. everything that has a package name starting with com.foo.common? Or
should log records generated by the common classes be written to the logs
of common.foo.baz or common.foo.fuzz, depending on which project invoked
the common code? For example, let's say that com.foo.Fuzz.Grunt1
instantiation com.foo.common.utilities.StringUtils and StringUtils wants
to log something. Should StringUtils write to a log that is associated
with com.foo.Fuzz or one that is associated with com.foo.common?
I think I'll have some followup questions once I've heard the answers to
these so I'll hold off for now.