logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: Logging for Different Packages: msg#00066

apache.logging.log4cxx.user

Subject: Re: Logging for Different Packages


On Dec 17, 2004, at 1:10 AM, Manish Moorjani wrote:

Hi All,

A have a ear, which consist of two components backend and frontend
Package structure is like
Abc.bcd.frontend.*
Abc.bcd.backend.*

I want to log the details of the packages in different log files(using
apache's log4j), can anyone help me in this?




You asked a log4j question on the log4cxx-user mailing list with a message that contained several hundred lines of list subscription fluff and HTML email. Not a great start.

You should read "A short intro to log4j" at http://logging.apache.org/log4j/docs/manual.html

The quick answer is that you define two file appenders in your configuration, call the backend and frontend and associate each with a corresponding logger with a configuration file like:

log4j.logger.Abc.bdc.frontend=info, frontend
log4j.appender.frontend=org.apache.log4j.FileAppender
log4j.appender.frontend.layout=org.apache.log4j.PatternLayout
log4j.appender.frontend.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.frontend.File=frontend.log
log4j.additivity.frontend=false

log4j.rootLogger=info, backend
log4j.appender.backend=org.apache.log4j.FileAppender
log4j.appender.backend.layout=org.apache.log4j.PatternLayout
log4j.appender.backend.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.backend.File=frontend.log



With this configuration, any logging request submitted to a logger that has a name starting with "Abc.bdc.frontend." will be logged to the frontend.log file. It won't go to backend.log since the loggers additivity is false. Any other logging request, will go the backend.log.

// would be appended to frontend.log
Logger.getLogger("Abc.bdc.frontend.someclass").info("Some Message");

// would be appended to backend.log
Logger.getLogger("Abc.bdc.backend.someclass").info("Some Message");




<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo