logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Madduri, Murthy" <Murthy.Madd...@fnf.com>
Subject RE: Different Log4j log file(s) based on Logging Level?
Date Fri, 11 Aug 2006 16:51:27 GMT
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. 

-----Original Message-----
From: James Stauffer [mailto:stauffer.james@gmail.com] 
Sent: Friday, August 11, 2006 12:31 PM
To: Log4J Users List
Subject: Re: Different Log4j log file(s) based on Logging Level?

Where would you want your new levels to fit into the current levels?
Currently there is debug, info, warn, error, and fatal.  Where do you
want to add your new levels in that list?

Here is an example of how you would use different logger hierarchies:
Logger logger = Logger.getLogger(getClass().getName());
Logger configLogger = Logger.getLogger("config." +
getClass().getName());
Logger businessLogger = Logger.getLogger("business." +
getClass().getName());

On 8/11/06, Madduri, Murthy <Murthy.Madduri@fnf.com> wrote:
> We have hierarchical logging in our applications.
> But, this requirement is to have the logs grouped based on a custom
> level.
> For a typical configuration transaction, the logger can record
messages
> from various hierarchies. We are not guaranteed of the sequence of
> messages in this whole transaction. We are pretty much getting all the
> messages, but, they ended up mixing with other trace statements.
>
> For example, if we have a new custom log level, can we use that in
> <logger> configuration like this?
>         <logger name="com.logging.test">
>
>                 <!-- Logging level (i.e. WARN) for this logger: -->
>                 <level value="CONFIG" />
>
>                 <!-- File appender for this logger: -->
>                 <appender-ref ref="fileAppender" />
>         </logger>
>
>
> -----Original Message-----
> From: James Stauffer [mailto:stauffer.james@gmail.com]
> Sent: Friday, August 11, 2006 11:46 AM
> To: Log4J Users List
> Subject: Re: Different Log4j log file(s) based on Logging Level?
>
> Have you considered having separate logging hierarchies instead?  That
> is often a better solution.
>
> On 8/11/06, Madduri, Murthy <Murthy.Madduri@fnf.com> wrote:
> > Hi,
> >
> >
> >
> > We are using log4j for our core business framework and it works
fine.
> >
> > One of recent requirements is that we need to capture different
> logging
> > events: very much customized.
> >
> > For example, they need a Configurations event, Business Activity
event
> > etc.
> >
> >
> >
> > 1)       Is there a way we can extend the org.apache.log4j.Level
> class?
> > Can we have our own logging levels?
> >
> > 2)       If so, can we re-direct the different logging levels into
> > different log files? For example, all the log statements with
> > com.test.logging.Level.CONFIG(a custom level) should be directed to
> > myapp-config.log and vice versa.
> >
> > 3)       In a J2EE application, how can we use a different log4j
> > configuration file name, NOT the default log4j.xml or
log4j.proprties?
> >
> >
> >
> > Any help is appreciated.
> >
> >
> >
> > Thanks & Regards
> > Murthy Madduri
> > * (770)263-1231
> > * Email: murthy.madduri@fnf.com
> >
> >
> >
> >
> >
>
>
> --
> 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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
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



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


Mime
View raw message