logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Stauffer" <stauffer.ja...@gmail.com>
Subject Re: Different Log4j log file(s) based on Logging Level?
Date Fri, 11 Aug 2006 17:00:22 GMT
You could easily not using sub-logger levels under your custom loggers
-- but using them gives you a little extra info (that you could easily
just not use unless you find a need).

Logger logger = Logger.getLogger(getClass().getName());
Logger configLogger = Logger.getLogger("config");
Logger businessLogger = Logger.getLogger("business");

Either way you can easily group the messages with:
<logger name="business">
    <appender-ref ref="fileAppender" />

If you won't want your normal logs to include business info then you
don't configure the root logger and attach your normals appender to
<logger name="com">
    <appender-ref ref="normalFileAppender" />

On 8/11/06, Madduri, Murthy <Murthy.Madduri@fnf.com> wrote:
> James,
> The custom levels I intend to have are not packages.
> So, even if I get a logger basing on
> Logger configLogger = Logger.getLogger("config." +
> getClass().getName());
> I guess this returns a logger that was defined as config.xxx.xxx.
> But, our package hierarchies do not reflect the custom logging levels
> like config, business activity. They could be normal com.xxx.util or
> com.xxx.services. In other words, if I have a Business  Activity
> Transaction that can kick at com.xxx.mvc.MyClass -> com.xxx.lookup ->
> com.xxx.util -> com.xxx.services -> com.xxx.dataacess. In this path, it
> logs different messages from all these packages and classes. Now, if we
> want to group just these messages, how can I do that? If I have a custom
> level that says BUSACT, then I can log all these messages in different
> classes with the Level BUSACT and define a logger that looks at all
> com.xxx AND BUSACT and use an appender to write to a file.

James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message